mysqli::$host_info
mysqli::$host_info
mysqli_get_host_info
(PHP 5, PHP 7)
mysqli :: $ host_info - mysqli_get_host_info - 返回一个表示所用连接类型的字符串
Description
面向对象的风格
string $mysqli->host_info;
程序风格
string mysqli_get_host_info ( mysqli $link )
返回描述由link
参数表示的连接的字符串(包括服务器主机名)。
Parameters
`link`
仅过程样式:由mysqli_connect()或mysqli_init()返回的链接标识符
Return Values
表示服务器主机名和连接类型的字符串。
Examples
Example #1 $mysqli->host_info example
面向对象的风格
<?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
?>
上面的例子会输出:
主机信息:通过UNIX套接字的本地主机
© 1997–2017 The PHP Documentation Group
根据知识共享署名许可证v3.0或更高版本授权。