mysqli::$server_info
mysqli::get_server_info
mysqli_get_server_info
(PHP 5, PHP 7, PHP 8)
mysqli::$server_info -- mysqli::get_server_info -- mysqli_get_server_info — 返回 MySQL 服务器的版本号
说明
面向对象风格
过程化风格
返回字符串,表示 MySQLi 扩展连接的 MySQL 服务器的版本号。
返回值
表示服务器版本的字符串。
示例
示例 #1 $mysqli->server_info 示例
面向对象风格
<?php
mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT);
$mysqli = new mysqli("localhost", "my_user", "my_password");
/* print server version */
printf("Server version: %s\n", $mysqli->server_info);
过程化风格
<?php
mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT);
$link = mysqli_connect("localhost", "my_user", "my_password");
/* print server version */
printf("Server version: %s\n", mysqli_get_server_info($link));
以上示例的输出类似于:
Server version: 8.0.21
参见
- mysqli_get_client_info() - 获取 MySQL 客户端信息
- mysqli_get_client_version() - 作为整数返回 MySQL 客户端的版本
- mysqli_get_server_version() - 作为一个整数返回MySQL服务器的版本
+添加备注
用户贡献的备注 1 note
it-solutions at schultz dot ch ¶
9 years ago
Please note that this property returns different versionstrings for MariaDB instances on LINUX and WINDOWS environments.
For a MariaDB instance 10.0.17:
on LINUX, this returns strings like "10.0.17-MariaDB-log"
on WINDOWS environments, this returns strings like "5.5.5-10.0.17-MariaDB-log"
To avoid this extra "5.5.5" on windows environments, you could use the SQL query "select version();" rather than this property of the mysqli extension
备份地址:http://www.lvesu.com/blog/php/mysqli.get-server-info.php