connection_status() 函数于 PHP
connection_status() 函数返回连接状态。
语法
connection_status()
参数
无
返回值
connection_status() 函数返回下列可能值。此即状态位域 −
0 - CONNECTION_NORMAL - 连接正常运行
1 - CONNECTION_ABORTED - 连接被用户或网络错误终止
2 - CONNECTION_TIMEOUT - 连接超时
3 - CONNECTION_ABORTED & CONNECTION_TIMEOUT
实例
以下是一个实例 −
<?php switch (connection_status()) { case CONNECTION_NORMAL: $msg = 'Connection is in a normal state!'; break; case CONNECTION_ABORTED: $msg = 'Connection aborted!'; break; case CONNECTION_TIMEOUT: $msg = 'Connection timed out!'; break; case (CONNECTION_ABORTED & CONNECTION_TIMEOUT): $msg = 'Connection aborted and timed out!'; break; default: $msg = 'Status is unknown!'; break; } echo $msg; ?>
广告