How do I write a PHP script that continues running, even after flushing out some text and ending the HTTP request? Is this possible?
相关问题
- Views base64 encoded blob in HTML with PHP
- Angular RxJS mergeMap types
- Laravel Option Select - Default Issue
- PHP Recursively File Folder Scan Sorted by Modific
- Can php detect if javascript is on or not?
To run PHP app forever or until php terminates
You might be interested by the
ignore_user_abort
configuration directive, and/or theignore_user_abort
function :Using this, you could :
flush
and/orob_flush
ignore_user_abort
(either now or before)The user's browser will probably still indicate "waiting" or "loading", but the content of the page will be loaded and displayed -- and even if the user presses "stop", your script should continue its execution.
For more informations, there is an example on the manual's page of that function -- and you can take a look at this article : How to Use
ignore_user_abort()
to Do Processing Out of BandOf course, while this can be used for some light process (like "cleaning up" stuff at the end of a page, while displaying it as fast as possible to the user), you'll still be limited by
max_execution_time
and the like.So, this is not a solution that should be used for long/heavy calculations.