PHP 8.3.4 Released!

mysql_get_host_info

(PHP 4 >= 4.0.5, PHP 5)

mysql_get_host_info取得 MySQL 主机信息

警告

本扩展自 PHP 5.5.0 起已废弃,并在自 PHP 7.0.0 开始被移除。应使用 MySQLiPDO_MySQL 扩展来替换之。参见 MySQL:选择 API 指南来获取更多信息。用以替代本函数的有:

说明

mysql_get_host_info(resource $link_identifier = NULL): string|false

描述 connection 中使用的连接类型,包括服务器主机名。

参数

link_identifier

MySQL 连接。如不指定连接标识,则使用由 mysql_connect() 最近打开的连接。如果没有找到该连接,会尝试不带参数调用 mysql_connect() 来创建。如没有找到连接或无法建立连接,则会生成 E_WARNING 级别的错误。

返回值

Returns a string describing the type of MySQL connection in use for the connection 或者在失败时返回 false.

示例

示例 #1 mysql_get_host_info() 示例

<?php
$link
= mysql_connect('localhost', 'mysql_user', 'mysql_password');
if (!
$link) {
die(
'Could not connect: ' . mysql_error());
}
printf("MySQL host info: %s\n", mysql_get_host_info());
?>

以上示例的输出类似于:

MySQL host info: Localhost via UNIX socket

参见

add a note

User Contributed Notes

There are no user contributed notes for this page.
To Top