PHP connection_status () function
Examples
Returns the 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;
?>
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;
?>
Running instance »
Definition and Usage
connection_status () function returns the current connection status.
The possible values can be returned:
- 0 - CONNECTION_NORMAL - connected to a functioning
- 1 - CONNECTION_ABORTED - connection error terminated by the user or the network
- 2 - CONNECTION_TIMEOUT - Connection Timeout
- 3 - CONNECTION_ABORTED & CONNECTION_TIMEOUT
grammar
connection_status()
technical details
return value: | Returns the connection status bit field. |
---|---|
PHP version: | 4+ |
PHP Misc Reference Manual