PHP 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: $txt = '连接状态正常'; break; case CONNECTION_ABORTED: $txt = '连接已中止'; break; case CONNECTION_TIMEOUT: $txt = '连接超时'; break; case (CONNECTION_ABORTED & CONNECTION_TIMEOUT): $txt = '连接已中止并超时'; break; default: $txt = '未知'; break; } echo $txt; ?>
语法
connection_status()
技术细节
返回值: | 返回连接状态位字段(实际上是一个整数,表示当前连接的状态)。 |
---|---|
PHP 版本: | 4+ |