PHP mysqli_get_server_info() Function
In this chapter you will learn:
- Definition for PHP mysqli_get_server_info() Function
- Syntax for PHP mysqli_get_server_info() Function
- Parameter for PHP mysqli_get_server_info() Function
- Return for PHP mysqli_get_server_info() Function
- Example - gets the MySQL server version
- Example - Object oriented style
Definition
The mysqli_get_server_info() function returns the MySQL server version.
Syntax
PHP mysqli_get_server_info() Function has the following syntax.
mysqli_get_server_info(connection);
Parameter
Parameter | Is Required | Description |
---|---|---|
connection | Required. | MySQL connection |
Return
The mysqli_get_server_info() function returns the MySQL server version.
Example 1
The following code gets the MySQL server version.
<?php//from j a va 2 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_info($con);
mysqli_close($con);
?>
Example 2
Object oriented style
<?php//from java 2 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();
?>
Next chapter...
What you will learn in the next chapter:
- Definition for PHP mysqli_get_server_version() Function
- Syntax for PHP mysqli_get_server_version() Function
- Parameter for PHP mysqli_get_server_version() Function
- Return for PHP mysqli_get_server_version() Function
- Example - Get the MySQL server version as an integer
- Example - Object oriented style
Home » PHP Tutorial » PHP MySQLi Functions