关闭指定的连接并释放相关资源。
下面的示例将关闭一个连接。此示例假定在本地计算机上已安装 SQL Server。从命令行运行此示例时,所有的输出都将写入控制台。
<?php /*Connect to the local server using Windows Authentication and specify the AdventureWorks database as the database in use. */ $serverName = "(local)"; $conn = sqlsrv_connect( $serverName); if( $conn === false ) { echo "Could not connect.\n"; die( print_r( sqlsrv_errors(), true)); } //----------------------------------------------- // Perform operations with connection here. //----------------------------------------------- /* Close the connection. */ sqlsrv_close( $conn); echo "Connection closed.\n"; ?>