小码哥的IT人生

首页 > PHP > php基础

PHP connection_status() 函数 详解

php基础 2022-06-07 17:11:08小码哥的IT人生shichen

PHP connection_status() 函数

定义和用法

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

可返回的可能值:

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

语法

connection_status()

实例

<?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;
?>

版权所有 © 小码哥的IT人生
Copyright © phpcodeweb All Rights Reserved
ICP备案号:苏ICP备17019232号-2  

苏公网安备 32030202000762号

© 2021-2024