php8.5
Home/ Manual/ mysqli / mysqli/ mysqli::$host_info

mysqli::$host_info

PHP function Edit on GitHub ✎

Returns a string representing the type of connection used

Description

Oop

stringmysqli->host_info

Procedural

mysqli_get_host_info(mysqli $mysql): string

Returns a string describing the connection represented by the mysql parameter (including the server host name).

Parameters

Return Values

A character string representing the server hostname and the connection type.

Examples

$mysqli->host_info example

Oop

php
<?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);

Procedural

php
<?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));

Outputs

output
Host info: Localhost via UNIX socket

See Also

Source: reference/mysqli/mysqli/get-host-info.xml · from the official PHP manual (php/doc-en)