PHP mysqli_get_server_version() Function

Definition

The mysqli_get_server_version() function returns the MySQL server version as an integer.

Syntax

mysqli_get_server_version(connection);

Parameter

ParameterIs RequiredDescription
connectionRequired.MySQL connection

Return

The mysqli_get_server_version() function returns the MySQL server version as an integer.

Example 1

The following code gets the MySQL server version as an integer.

For example, 5.1.0 is returned as 50100.


<?php/*w w w .  j  a  v a2  s . c o m*/
$con=mysqli_connect("localhost","my_user","my_password","my_db");

if (mysqli_connect_errno($con)){
  echo "Failed to connect to MySQL: " . mysqli_connect_error();
}

echo mysqli_get_server_version($con);

mysqli_close($con);
?>

Example 2

Object oriented style


<?php//from w  ww.j  a  va  2  s. co m
$mysqli = new mysqli("localhost", "my_user", "my_password");

if (mysqli_connect_errno()) {
    printf("Connect failed: %s\n", mysqli_connect_error());
    exit();
}

print $mysqli->server_version;

$mysqli->close();
?>




















Home »
  PHP Tutorial »
    Function reference »




PHP Array Functions
PHP Calendar Functions
PHP Class Functions
PHP Data Type Functions
PHP Date Functions
PHP File Functions
PHP Image Functions
PHP Math Functions
PHP MySQLi Functions
PHP SimpleXML Functions
PHP String Functions
PHP XML Functions
PHP Zip Functions