The mysqli_get_server_info() function returns the MySQL server version.
PHP mysqli_get_server_info() Function has the following syntax.
mysqli_get_server_info(connection);
Parameter | Is Required | Description |
---|---|---|
connection | Required. | MySQL connection |
The mysqli_get_server_info() function returns the MySQL server version.
The following code gets the MySQL server version.
<?php//from www . ja v a 2 s . com
$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_info($con);
mysqli_close($con);
?>
Object oriented style
<?php/*w ww . ja va2 s . c o m*/
$mysqli = new mysqli("localhost", "my_user", "my_password");
if (mysqli_connect_errno()) {
printf("Connect failed: %s\n", mysqli_connect_error());
exit();
}
printf("Server version: %s", $mysqli->server_info);
$mysqli->close();
?>