Re: Alternatives to Flush()
| From: | speedfreak at chello dot be | Date: | Wed, 24 Mar 2004 23:41:54 +0000 |
| Subject: | Re: Alternatives to Flush() | ||
| References: | 1 | Groups: | php.general php.general |
| Request: | Send a blank email to php-general+get-181417@lists.php.net to get a copy of this message | ||
Ron Stagg wrote on 24/03/04 22:02:
I have a particular PHP web page that can take over an hour to process. When visitors come to this page, I want the code to redirect them to a separate page at my site. After the redirection, I want the PHP script to continue operating on its own until the process is complete. I am attempting to implement this is by sending a "Location" header to the client. This header is sent out near the top of the script. After sending the header, I call Flush(), then the script continues into the heavy lifting. Finally, the script quietly terminates with an exit call. Neither the flush() or ob_flush() calls are working (I even tried calling them both). Regardless of what I do, the server will not send the "Location" header until the script has completely terminated. It appears that my hosting provider has Flush() disabled. I have thought about using Chron to accomplish this. However, the smallest Chron resolution is minutes. This could cause the visitor to wait for up to a minute before Chron wakes up and starts working on the process. There has got to be a better way. Does anybody have any recommendations? Thanks, RonI could be completely misreading the issue here, but it is perfectly possible to use a "Location" header redirect in combination with further script execution in the background using PHP's register_shutdown_function(). The specifics and complexity of your actual script are unknown to the list, so I can only refer you to the manual (and the user contributed notes) for further inspiration and investigation: http://www.php.net/manual/en/function.register-shutdown-function.php HTH, Dirk Maetens PHP hobbyist