MySQLi - Server Info
语法
string mysqli_get_server_info ( mysqli $link )
定义和用法
它返回 MySQL 服务器的版本。
示例
Try out following example −
<?php $servername = "localhost:3306"; $username = "root"; $password = ""; $dbname = "TUTORIALS"; $conn = new mysqli($servername, $username, $password, $dbname); if ($conn->connect_error) { die('Connect Error (' . mysqli_connect_errno() . ') '. mysqli_connect_error()); exit(); } if (!mysqli_query($conn, "SET a = 1")) { printf("Errorcode: %d ", mysqli_error($conn)); } echo 'Success... ' . mysqli_get_host_info($conn) . " "; printf("Server version: %s ", $conn->server_info); $conn->close(); ?>
上述代码的示例输出应该是这样的 −
Errorcode: 0 Success... localhost:3306 via TCP/IP Server version: 5.5.5-10.1.21-MariaDB