PHP connection_aborted() Function
Definition and Usage
The connection_aborted() function checks if the client has been disconnected.
If the connection has been aborted, this function returns 1, otherwise it returns 0.
Syntax
connection_aborted()
Example
Create a function to write a log message when the client terminates the script:
<?php function check_abort() { if (connection_aborted()) error_log("Script $GLOBALS[SCRIPT_NAME]" "$GLOBALS[SERVER_NAME] was aborted by the user."); } // Some code to be executed // Call the check_abort function at the end of the script register_shutdown_function("check_abort"); ?>