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



Become a Patron!

Follow us on Facebook and Twitter for latest update.

It will be nice if you may share this link in any developer community or anywhere else, from where other developers may find this content. Thanks.

https://w3resource.com/php/function-reference/mysqli_server_version.php