Detect browser connection closed in PHP
问题 Does anyone know if it is possible to detect whether the browser has closed the connection during the execution of a long PHP script, when using apache and mod_php ? For example, in Java , the HttpOutputStream will throw an exception if one attempts to write to it after the browser has closed it -- Or will respond negatively to checkError() . 回答1: Use connection_aborted() 回答2: In at least PHP4, connection_aborted and connection_status only worked after the script sent any output to the