The mysqli_get_host_info() function returns the MySQL server hostname and the connection type.
Object oriented style
string $mysqli->host_info;
Procedural style
string mysqli_get_host_info ( mysqli $link )
Parameter | Is Required | Description |
---|---|---|
connection | Required. | MySQL connection |
A character string representing the server hostname and the connection type.
The following code gets the MySQL server hostname and connection type.
<?php/*ww w. 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_host_info($con);
mysqli_close($con);
?>
Object orient version
<?php//from w w w .ja va 2s . c o m
$mysqli = new mysqli("localhost", "my_user", "my_password", "world");
if (mysqli_connect_errno()) {
printf("Connect failed: %s\n", mysqli_connect_error());
exit();
}
print $mysqli->host_info;
$mysqli->close();
?>