Skip to content
Advertisement

Does PHP run in background when browser is closed?

I start my browser and run a PHP program (in another server) and them I close the browser, the program will still keep running in the server, right?

What if you run the program and them remove the folder in the server (while the program is running). Assuming its a single PHP file, will it crash? Does the whole PHP file is read in memory before running or do the system does periodic access for this file?

Advertisement

Answer

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.

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement