PHP connection_aborted()Functions

PHP Misc 参考手册PHP Misc Reference Manual

Examples

Create a function (check_abort()) that writes 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 script to be executed here

// Call the check_abort function when the script ends
register_shutdown_function("check_abort");
?>


Definition and Usage

The connection_aborted() function checks whether the client is disconnected.


Syntax

connection_aborted()

Technical Details

Return Value: Returns 1 if the connection was aborted, otherwise returns 0.
PHP Version: 4+


PHP Misc 参考手册PHP Misc Reference Manual Other Extensions