Detect browser connection closed in PHP

后端 未结 3 701
迷失自我
迷失自我 2021-01-12 12:11

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

3条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-01-12 13:08

    In at least PHP4, connection_aborted and connection_status only worked after the script sent any output to the browser (using: flush() | ob_flush()). Also don't expect accurately timed results.

    It's mostly useful to check if there is still someone waiting on the other side.

提交回复
热议问题