PHP connection_status() 関数

定義と用法

connection_status() 関数は現在の接続状態を返します。

可能な返り値:

  • 0 - CONNECTION_NORMAL - 接続が通常の状態です
  • 1 - CONNECTION_ABORTED - 接続がユーザーやネットワークエラーで切断されました
  • 2 - CONNECTION_TIMEOUT - 接続タイムアウト
  • 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;
?>