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

PHP Basic Tutorial

PHP Advanced Tutorial

PHP & MySQL

PHP Reference Manual

PHP mysqli_get_client_version() Function Usage and Example

PHP MySQLi Reference Manual

Definition and Usage

mysqli_get_client_version()The function returns the version of the MySQL client as an integer.

Syntax

mysqli_get_client_version($con);

Parameter

Serial NumberParameters and Description
1

con(Required)

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

Return Value

The mysqli_get_client_version() function returns an integer representing the MySQL client library version.

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_version()Function usage (procedural style), returns the client library version number:

<?php
   //Client library version
   $version = mysqli_get_client_version();
   print("Client library version number:  "$version");
?>

Output Result

Client library version number: 70405

Online Example

In the object-oriented style, the syntax of this function is$con-> client_version. Here is an example of the function in an object-oriented style-

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

Output Result

Client library version number: 70405

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 number
   $version = mysqli_get_client_version($con);
   print("Client library version number:  "$version");
   //Close Connection
   mysqli_close($con);
?>

Output Result

Client library version number: 70405

Online Example

Return the MySQL client library version as an integer:

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

Output Result

70405

PHP MySQLi Reference Manual