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 服务器的版本号

说明

面向对象风格

public mysqli::get_server_info(): string

过程化风格

mysqli_get_server_info(mysqli $mysql): string

返回字符串,表示 MySQLi 扩展连接的 MySQL 服务器的版本号。

参数

mysql

仅以过程化样式:由 mysqli_connect()mysqli_init() 返回的 mysqli 对象。

返回值

表示服务器版本的字符串。

示例

示例 #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

参见

add a note add a note

User Contributed Notes 1 note

up
2
it-solutions at schultz dot ch
8 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
To Top