Home > Article > Backend Development > How to continue processing after PHP access ends
Today I saw someone in dewen asking how to use php to continue executing the subsequent code after the browser access is completed, I wrote a demo, it is very easy to implement in the php-fpm environment, fastcgi_finish_request is enough. If it is another container, I think the jump can only be achieved by outputting javascript to the client, and then continuing execution in the background.
The demo is as follows, php-fpm test is available, apache php-cgi is not tested because there is no environment. (Recommended learning: PHP video tutorial)
location='$url'"; ob_flush(); flush(); } // 这里是模拟你的耗时逻辑 sleep(2); file_put_contents('/tmp/test.log', 'ok');
The above is the detailed content of How to continue processing after PHP access ends. For more information, please follow other related articles on the PHP Chinese website!