• PHP Video Tutorials

PHP mysqli_get_client_info() Function



Definition and Usage

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

Syntax

mysqli_get_client_info([$con]);

Parameters

Sr.No Parameter & Description
1

con(Optional)

This is an object representing a connection to MySQL Server.

Return Values

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

PHP Version

This function was first introduced in PHP Version 5 and works works in all the later versions.

Example

Following example demonstrates the usage of the mysqli_get_client_info() function (in procedural style) −

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

This will produce following result −

Client Library: mysqlnd 7.4.5

Example

In object oriented style the syntax of this function is $con -> client_info. Following is the example of this function in object oriented style −

<?php
   //Creating a connection
   $con = new mysqli("localhost", "root", "password", "mydb");

   //Client library version
   $info = $con->client_info;
   print("Client Library Version: ".$info);

   //Closing the connection
   $con -> close();
?>

This will produce following result −

Client Library Version: mysqlnd 7.4.5

Example

Now lets try invoking this function by passing the optional parameter (connection object) −

<?php
   //Creating a connection
   $con = mysqli_connect("localhost", "root", "password", "mydb");

   //Client library version
   $info = mysqli_get_client_info($con);
   print("Client Library Version: ".$info);

   //Closing the connection
   mysqli_close($con);
?>

This will produce following result −

Client Library: mysqlnd 7.4.5

Example

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

This will produce following result −

mysqlnd 7.4.5
php_function_reference.htm
Advertisements