I have the following code:
ignore_user_abort(true); while(!connection_aborted()) { // do stuff }
and according to the PHP documentation
Try:
ignore_user_abort(true); echo "Testing connection handling"; while (1) { if (connection_status() != CONNECTION_NORMAL) break; sleep(1); echo "test"; flush(); }