PHP 8.1.28 Released!

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_report
(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT);
$mysqli = new mysqli("localhost", "my_user", "my_password", "world");

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

过程化风格

<?php

mysqli_report
(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT);
$link = mysqli_connect("localhost", "my_user", "my_password", "world");

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

以上示例会输出:

Host info: Localhost via UNIX socket

参见

add a note

User Contributed Notes

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