The mysqli_get_server_version() function returns the MySQL server version as an integer.
mysqli_get_server_version(connection);
Parameter | Is Required | Description |
---|---|---|
connection | Required. | MySQL connection |
The mysqli_get_server_version() function returns the MySQL server version as an integer.
The following code gets the MySQL server version as an integer.
For example, 5.1.0 is returned as 50100.
<?php//from www .j a va2s .co 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);
?>
Object oriented style
<?php//from w w w . j a v a 2s . c o 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();
?>