Does PHP run in background when browser is closed?

draft saved First off, when the server receives a request, it will continue to process that request until it finishes it's response, even if the browser that made the request closes.

The PHP file call is loaded into memory and processed, so deleting the file in the middle of processing will not cause anything to crash.

If however, half way through your PHP it references another file that is deleted BEFORE that code is reached, then it may crash (based on your error handling).

Note however, that causing PHP to crash will not crash the whole web server.


According to the PHP Connection Handling Page: http://php.net/manual/en/features.connection-handling.php

You can decide whether or not you want a client disconnect to cause your script to be aborted. Sometimes it is handy to always have your scripts run to completion even if there is no remote browser receiving the output.

Of course you can delete the file or folder which includes the PHP file as long as it is not directly in use/open on the server. Otherwise you could never delete files on a Webserver as they always might be in use :-)

Tags:

Php

Connection