Continue PHP execution after sending HTTP response

peestiode

New Member
How can I have PHP 5.2 (running as apache mod_php) send a complete HTTP response to the client, and then keep executing operations for one more minute? The long story:I have a PHP script that has to execute a few long database requests and send e-mail, which takes 45 to 60 seconds to run. This script is called by an application that I have no control over. I need the application to report any error messages received from the PHP script (mostly invalid parameter errors). The application has a timeout delay shorter than 45 seconds (I do not know the exact value) and therefore registers every execution of the PHP script as an error. Therefore, I need PHP to send the complete HTTP response to the client as fast as possible (ideally, as soon as the input parameters have been validated), and then run the database and e-mail processing. I'm running mod_php, so \[code\]pcntl_fork\[/code\] is not available. I could work my way around this by saving the data to be processed to the database and run the actual process from \[code\]cron\[/code\], but I'm looking for a shorter solution.
 
Back
Top