php8.5
Home/ Manual/ sqlsrv / functions/ sqlsrv_server_info

sqlsrv_server_info

PHP function Edit on GitHub ✎

Returns information about the server

Description

sqlsrv_server_info(resource $conn): array

Returns information about the server.

Parameters

conn

The connection resource that connects the client and the server.

Return Values

Returns an array as described in the following table:

CurrentDatabaseThe connected-to database.
SQLServerVersionThe SQL Server version.
SQLServerNameThe name of the server.

Examples

sqlsrv_server_info() example

php
<?php
$serverName = "serverName\sqlexpress";
$conn = sqlsrv_connect( $serverName);
if( $conn === false ) {
     die( print_r( sqlsrv_errors(), true));
}

$server_info = sqlsrv_server_info( $conn);
if( $server_info )
{
    foreach( $server_info as $key => $value) {
       echo $key.": ".$value."<br />";
    }
} else {
      die( print_r( sqlsrv_errors(), true));
}
?>

See Also

Source: reference/sqlsrv/functions/sqlsrv-server-info.xml · from the official PHP manual (php/doc-en)