Current Location: Home> Function Categories> get_host_info

get_host_info

Returns the MySQL server hostname and connection type.
Name:get_host_info
Category:Uncategorized
Programming Language:php
One-line Description:Returns the MySQL server hostname and connection type.

Definition and usage

host_info() / mysqli_get_host_info() function returns the MySQL server host name and connection type.

Example

Example 1 - Object-Oriented Style

Returns the server hostname and connection type:

 <?php
$mysqli = new mysqli ( "localhost" , "my_user" , "my_password" , "my_db" ) ;

if ( $mysqli -> connect_errno ) {
  echo "Failed to connect to MySQL: " . $mysqli -> connect_error ;
  exit ( ) ;
}

echo $mysqli -> host_info ( ) ;

$mysqli -> close ( ) ;
?>

Example 2 - Procedural Style

Returns the server hostname and connection type:

 <?php
$con = mysqli_connect ( "localhost" , "my_user" , "my_password" , "my_db" ) ;

if ( mysqli_connect_errno ( ) ) {
  echo "Failed to connect to MySQL: " . mysqli_connect_error ( ) ;
  exit ( ) ;
}

echo mysqli_get_host_info ( $con ) ;

mysqli_close ( $con ) ;
?>
Similar Functions
Popular Articles