Home  >  Article  >  Backend Development  >  How to continue processing after PHP access ends

How to continue processing after PHP access ends

(*-*)浩
(*-*)浩Original
2019-10-16 11:32:472063browse

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.

How to continue processing after PHP access ends

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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn