Create a function (check_abort()) that writes a log message if a client aborts the script in PHP

Description

The following code shows how to create a function (check_abort()) that writes a log message if a client aborts the script.

Example


  //ww w.  j a  va  2s.c o  m
<?php
    function check_abort(){
      if (connection_aborted())
          error_log ("Script $GLOBALS[SCRIPT_NAME]" . "$GLOBALS[SERVER_NAME] was aborted by the user.");
      }
    
    // Some script to be executed here
    
    // Call the check_abort function when the script ends
    register_shutdown_function("check_abort");
?>




















Home »
  PHP Tutorial »
    Development »




Environment
Error
Hash
Include
Locale
Math
Network
Output
Reflection
PHP Regular Expressions