connection_aborted

int connection_aborted(void) 

Checks whether the remote client has disconnected.

Returns:

1 if the connection has been aborted; 0 for all other cases

Description:

connection_aborted() checks whether the remote client has disconnected, either because of a network error or via the browser’s stop functionality. This function can be used in conjunction with the register_shutdown_function() and ignore_user_abort() functions to allow developers to handle cases in which the client aborts the script before it completes running.

See also:

To deal with a terminated connection:

register_shutdown_function() 

To ignore user aborts:

ignore_user_abort() 

Version:

3.0.7+, 4.0b4+

Example:

Write a log message if the client aborts the script ...

Get PHP Functions Essential Reference now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.