PHP 8.3.4 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 が使用している接続の情報を文字列で返します(サーバーのホスト名を 含みます)。

パラメータ

link

手続き型のみ: 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");

/* ホスト情報を表示します */
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");

/* ホスト情報を表示します */
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