English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

PHP Basic Tutorial

PHP Advanced Tutorial

PHP & MySQL

PHP Reference Manual

PHP mysqli_get_client_info() Function Usage and Example

PHP MySQLi Reference Manual

The mysqli_get_client_info() function returns the version of the MySQL client library.

Definition and Usage

mysqli_get_client_info()The function is used to obtain information about the underlying MySQL client (version).

Syntax

mysqli_get_client_info([$con]);

Parameter

Serial NumberParameters and Description
1

con (optional)

This is an object representing the connection to the MySQL Server.

Return Value

The mysqli_get_client_info() function returns a string representing the version of the underlying MySQL client library.

PHP Version

This function was originally introduced in PHP version5introduced and can be used in all higher versions.

Online Example

The following examples demonstratemysqli_get_client_info()Function Usage (Procedural Style)-

<?php
   $info = mysqli_get_client_info();
   print("Client library version: " . $info);
?>

Output Result

Client library version: mysqlnd 7.4.5

Online Example

In object-oriented style, the syntax of this function is$con-> client_info. The following is an example of the function in object-oriented style-

<?php
   //Establish Connection
   $con = new mysqli("localhost", "root", "password", "mydb");
   //Client library version
   $info = $con-> client_info;
   print("Client library version: " . $info);
   //Close Connection
   $con -> close();
?>

Output Result

Client library version: mysqlnd 7.4.5

Online Example

Now let's try to call this function by passing an optional parameter (connection object)-

<?php
   //Establish Connection
   $con = mysqli_connect("localhost", "root", "password", "mydb");
   //Client library version
   $info = mysqli_get_client_info($con);
   print("Client library version: " . $info);
   //Close Connection
   mysqli_close($con);
?>

Output Result

Client library version: mysqlnd 7.4.5

Online Example

Return MySQL client library version:

<?php
   $connection_mysql = mysqli_connect("localhost","user","password","mydb");
   
   if (mysqli_connect_errno($connection_mysql)){
      echo "Unable to connect to MySQL: " . mysqli_connect_error();
   }
   
   print_r(mysqli_get_client_info($connection_mysql));
   
   mysqli_close($connection_mysql);
?>

Output Result

mysqlnd 7.4.5

PHP MySQLi Reference Manual