PHP connection_status() 函数


定义和用法

connection_status() 函数返回当前的连接状态。

可返回的可能值:

  • 0 - CONNECTION_NORMAL - 连接运行正常
  • 1 - CONNECTION_ABORTED - 连接由用户或网络错误终止
  • 2 - CONNECTION_TIMEOUT - 连接超时
  • 3 - CONNECTION_ABORTED & CONNECTION_TIMEOUT
    语法
  1. connection_status()

例子

  1. <?php
  2. switch (connection_status())
  3. {
  4. case CONNECTION_NORMAL:
  5. $txt = 'Connection is in a normal state';
  6. break;
  7. case CONNECTION_ABORTED:
  8. $txt = 'Connection aborted';
  9. break;
  10. case CONNECTION_TIMEOUT:
  11. $txt = 'Connection timed out';
  12. break;
  13. case (CONNECTION_ABORTED &amp; CONNECTION_TIMEOUT):
  14. $txt = 'Connection aborted and timed out';
  15. break;
  16. default:
  17. $txt = 'Unknown';
  18. break;
  19. }
  20. echo $txt;
  21. ?>

分类导航