Current Location: Home> Function Categories> mysql_get_host_info

mysql_get_host_info

Get MySQL host information.
Name:mysql_get_host_info
Category:Uncategorized
Programming Language:php
One-line Description:Get the MySQL host information for the currently connected

Function: mysql_get_host_info()

Applicable version: PHP 4, PHP 5, PHP 7

Usage: The mysql_get_host_info() function is used to obtain the MySQL host information of the currently connected.

Syntax: string mysql_get_host_info ([ resource $link_identifier = NULL ] )

parameter:

  • link_identifier (optional): MySQL connection identifier. If this parameter is not provided, the last open connection is used by default.

Return value: Returns a string representing the current connection MySQL host information.

Example: <?php // Create a MySQL connection $link = mysql_connect('localhost', 'user', 'password'); if (!$link) { die('Could not connect: ' . mysql_error()); }

// Get the MySQL host information of the currently connected $host_info = mysql_get_host_info($link); echo "MySQL host info: " . $host_info;

// Close the connection mysql_close($link); ?> Output: MySQL host info: localhost via TCP/IP

Notes:

  • This function has been abandoned in PHP 5.5.0 and has been removed in PHP 7.0.0. It is recommended to use mysqli or PDO extensions instead of mysql functions.
  • If the link_identifier parameter is not provided, the function returns the host information for the last opened connection.
  • If the connection fails, the function returns false.
  • If the function is called after the connection is closed, a warning will be generated.
  • This function is only applicable to MySQL connections and not MySQLi or PDO connections.
Similar Functions
Popular Articles