title: Continue PHP execution after sending HTTP response
body: <p>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? </p>
  
  <p><strong>The long story:</strong></p>
  
  <p>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). </p>
  
  <p>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. </p>
  
  <p>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.</p>