Detecting browser connection closed in PHP

Does anyone know if it is possible to determine if the browser closed the connection during the execution of a long PHP script using apache and mod_php ?

For example, in Java HttpOutputStream will HttpOutputStream exception if you try to write it after closing the browser - or respond negatively to checkError() .

+6
php apache mod-php
source share
3 answers
+7
source share

At least PHP4, connection_aborted and connection_status only worked after the script sent any output to the browser (using: flush () | ob_flush ()). Also do not expect accurately calculated results.

It is mostly useful to check if there is someone else waiting on the other side.

+2
source share

http://nz.php.net/register-shutdown-function

It is probably less difficult if you just want the script to die and process it when the user shuts down.

(i.e. if it were a long search, it will save you a lot of work cycles)

+1
source share

All Articles