PHP connection_status() 函数
PHP connection_status() 函数返回当前的连接状态
( PHP >= 4.0.0 )
函数原型
connection_status()
返回值
返回连接状态位字段
可返回的可能常量:
常量 | 值 | 描述 |
---|---|---|
CONNECTION_NORMAL | 0 | 连接运行正常 |
CONNECTION_ABORTED | 1 | 连接由用户或网络错误终止 |
CONNECTION_TIMEOUT | 2 | 连接超时 |
CONNECTION_ABORTED | 3 | 连接被打断 |
CONNECTION_TIMEOUT | 4 | 连接被打断 |
范例
返回连接状态:
<?php switch (connection_status()) { case CONNECTION_NORMAL: $txt = 'Connection is in a normal state'; break; case CONNECTION_ABORTED: $txt = 'Connection aborted'; break; case CONNECTION_TIMEOUT: $txt = 'Connection timed out'; break; case (CONNECTION_ABORTED & CONNECTION_TIMEOUT): $txt = 'Connection aborted and timed out'; break; default: $txt = 'Unknown'; break; } echo $txt;