W3docs

get_client_info

In this article, we will focus on the mysqli_get_client_info() function in PHP, which is used to return the MySQL client library version. We will provide you

The mysqli_get_client_info() function returns the version of the MySQL client library that the MySQLi extension was built against. Here, client library means the C library (libmysqlclient or mysqlnd) that PHP uses to talk to MySQL — not your browser, your application, or the database server. This page explains the syntax, what the return value actually tells you, and how it differs from the related "server" and "client version" functions.

What is the client library?

When PHP communicates with MySQL, it does so through a low-level client library compiled into the MySQLi extension. On modern PHP installations this is almost always mysqlnd (the MySQL Native Driver), which ships with PHP itself; older or custom builds may use Oracle's libmysqlclient. mysqli_get_client_info() reports the version string of whichever one is in use, for example mysqlnd 8.1.0 or 8.0.30.

This is useful for:

  • Debugging connection issues that depend on the driver in use.
  • Logging environment details so a bug report includes the exact client build.
  • Verifying compatibility when a feature requires a minimum client library version.

Syntax

mysqli_get_client_info(?mysqli $mysql = null): string
ParameterDescription
$mysqlOptional. A connection link returned by mysqli_connect() / new mysqli(). This parameter is ignored in modern PHP — the value comes from the compiled-in library, not the connection — but is accepted for backward compatibility.

Return value: a string describing the MySQL client library version. No connection is required to call it.

Procedural example

Because the function reads a compile-time value, you do not even need a live database connection:

<?php
// No connection needed — this reflects the library PHP was built with
$client_info = mysqli_get_client_info();

printf("MySQL client library version: %s\n", $client_info);
?>

A typical output looks like this (the exact string depends on your PHP build):

MySQL client library version: mysqlnd 8.1.0

Object-oriented example

MySQLi also exposes this value through the client_info property and the mysqli::get_client_info() method:

<?php
$mysqli = new mysqli("localhost", "username", "password", "database");

if ($mysqli->connect_errno) {
    die("Connection failed: " . $mysqli->connect_error);
}

// Both lines print the same value
echo $mysqli->client_info . "\n";
echo $mysqli->get_client_info() . "\n";

$mysqli->close();
?>

Client library vs. client version vs. server info

These four functions are easy to confuse:

If you only need to make a numeric "is this version new enough?" check, prefer mysqli_get_client_version(). Use mysqli_get_client_info() when you want a human-readable label for logs.

Conclusion

mysqli_get_client_info() returns a human-readable string for the MySQL client library compiled into the MySQLi extension. It does not require a connection and is most useful for logging and diagnostics. For more on opening connections, see mysqli_connect() and the MySQLi overview.

Practice

Practice
What does mysqli_get_client_info() return?
What does mysqli_get_client_info() return?
Was this page helpful?