How to use connection status in PHP
In this article I am going to explain about connection_status function in PHP.
connection_status() Function
This function returns the current connection status.
Possible values that can be returned are:
- 0 - CONNECTION_NORMAL - connection is running normally
- 1 - CONNECTION_ABORTED - connection is aborted by user or network error
- 2 - CONNECTION_TIMEOUT - connection timed out
- 3 - CONNECTION_ABORTED & CONNECTION_TIMEOUT
Syntax
Example
<html>
<body>
<?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;
?>
</body>
<html>
|
Output

You may also want to read these related articles Click here
Ask Your Question
Got a programming related question? You may want to post your question here
Programming Answers here