php mysqli_get_host_info() 函数

时间:2017-03-03
php mysqli_get_host_info()函数获取MySQL服务器主机名和连接类型,本文章向大家介绍mysqli_get_host_info() 函数的基本使用方法和实例,需要的朋友可以参考一下。

定义

mysqli_get_host_info()函数返回MySQL服务器主机名和连接类型。

语法

面向对象的风格:

string $mysqli->host_info;

程序风格:

string mysqli_get_host_info ( mysqli $link )

参数

参数 是否必须 描述
link 需要。 MySQL连接

返回值

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

实例

以下代码获取MySQL服务器主机名和连接类型。

<?php
//  http://www.manongjc.com/article/1674.html
//  作者:码农教程
$con=mysqli_connect("localhost","my_user","my_password","my_db");

if (mysqli_connect_errno($con)){
  echo "Failed to connect to MySQL: " . mysqli_connect_error();
}

echo mysqli_get_host_info($con);

mysqli_close($con);
?>