w3resource

PHP mysqli: get_server_version() function

mysqli_get_server_version() function / mysqli::$server_version

The mysqli_get_server_version() function / mysqli::$server_version returns the MySQL server version as an integer.

Syntax:

mysqli_get_server_version(connection);

Parameter:

Name Description
connection Required. Specifies the MySQL connection to use

Return value:

An integer representing the server version.

The form of this version number is main_version * 10000 + minor_version * 100 + sub_version (i.e. version 4.1.0 is 40100).

Version: PHP 5, PHP 7

Example:

<?php
$con=mysqli_connect("localhost","user1","datasoft123","hr");
// Check connection
if (mysqli_connect_errno())
  {
  echo "Failed to connect to MySQL: " . mysqli_connect_error();
  }

echo mysqli_get_server_version($con);

mysqli_close($con);
?>

Sample Output:

50136

See also

PHP Function Reference

Previous: server_info
Next: get_warnings



Follow us on Facebook and Twitter for latest update.

PHP: Tips of the Day

To use the constant simply use its name:

Example:

if (EARTH_IS_FLAT) {
 print "Earth is flat";
}
print APP_ENV_UPPERCASE; 

Output:


or if you don't know the name of the constant in advance, use the constant function:

// this code is equivalent to the above code
$const1 = "EARTH_IS_FLAT";
$const2 = "APP_ENV_UPPERCASE";
if (constant($const1)) {
 print "Earth is flat";
}
print constant($const2);

Output:


 





We are closing our Disqus commenting system for some maintenanace issues. You may write to us at reach[at]yahoo[dot]com or visit us at Facebook