• PHP Video Tutorials

PHP mysqli_get_client_version() Function



Definition and Usage

The mysqli_get_client_version() function returns the version number of the underlying MySQL client.

Syntax

mysqli_get_client_version($con);

Parameters

Sr.No Parameter & Description
1

con(Mandatory)

This is an object representing a connection to MySQL Server.

Return Values

PHP mysqli_get_client_version() function returns a integer value 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_version() function (in procedural style) −

<?php
   //Client library version
   $version = mysqli_get_client_version();
   print("Client Library Version Number: ".$version);
?>

This will produce following result −

Client Library Version Number: 70405

Example

In object oriented style the syntax of this function is $con -> client_version. 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 number
   $version = $con->client_version;
   print("Client Library Version Number: ".$version);

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

This will produce following result −

Client Library Version Number: 70405

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
   $version = mysqli_get_client_version($con);
   print("Client Library Version Number: ".$version);

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

This will produce following result −

Client Library Version Number: 70405

Example

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

This will produce following result −

70405
php_function_reference.htm
Advertisements