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

sqlsrv_close

PHP function Edit on GitHub ✎

Closes an open connection and releases resources associated with the connection

Description

sqlsrv_close(resource $conn): bool

Closes an open connection and releases resources associated with the connection.

Parameters

conn

The connection to be closed.

Return Values

Success

Examples

sqlsrv_close() example

php
<?php
$serverName = "serverName\sqlexpres";
$connOptions = array("UID"=>"username", "PWD"=>"password", "Database"=>"dbname");
$conn = sqlsrv_connect( $serverName, $connOptions );
if( $conn === false ) {
     die( print_r( sqlsrv_errors(), true));
}

//-------------------------------------
// Perform database operations here.
//-------------------------------------

// Close the connection.
sqlsrv_close( $conn );
?>

See Also

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