mysqli::$host_info

mysqli_get_host_info

(PHP 5, PHP 7, PHP 8)

mysqli::$host_info -- mysqli_get_host_info返回表述使用的连接类型的字符串

说明

面向对象风格

过程化风格

mysqli_get_host_info(mysqli $mysql): string

返回由 mysql 参数表示连接的字符串描述(包括服务器主机名)。

参数

mysql

仅以过程化样式:由mysqli_connect()mysqli_init() 返回的 mysqli 对象。

返回值

表示服务器主机名和连接类型的字符串。

范例

示例 #1 $mysqli->host_info 示例

面向对象风格

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

/* check connection */
if (mysqli_connect_errno()) {
printf("Connect failed: %s\n", mysqli_connect_error());
exit();
}

/* print host information */
printf("Host info: %s\n", $mysqli->host_info);

/* close connection */
$mysqli->close();
?>

过程化风格

<?php
$link
= mysqli_connect("localhost", "my_user", "my_password", "world");

/* check connection */
if (mysqli_connect_errno()) {
printf("Connect failed: %s\n", mysqli_connect_error());
exit();
}

/* print host information */
printf("Host info: %s\n", mysqli_get_host_info($link));

/* close connection */
mysqli_close($link);
?>

以上例程会输出:

Host info: Localhost via UNIX socket

参见

add a note

User Contributed Notes

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