PHP/Utility Function/connection status

Материал из Web эксперт
Перейти к: навигация, поиск

int connection_status ( void ) returns 0 if the connection is live;

   <source lang="html4strict">

1 if the connection is aborted; 2 if the connection has been aborted; and 3 if the connection has been aborted and subsequently timed out.

<?

   function say_goodbye( ) {
           if (connection_status( ) =  = CONNECTION_TIMEOUT) {
                   print "Script timeout!\n";
           } else {
                   print "Goodbye!\n";
           }
   }
   register_shutdown_function("say_goodbye");
   set_time_limit(1);
   print "Sleeping...\n";
   sleep(2);
   print "Done!\n";

?>

 </source>