开发者

How to continue PHP script in background without holding up display to the user?

开发者 https://www.devze.com 2023-04-05 11:07 出处:网络
Suppose I have some operations (e.g database INSERT queries) that need to be done in the PHP script, but I want to finish displaying the page to the user first before executing them.

Suppose I have some operations (e.g database INSERT queries) that need to be done in the PHP script, but I want to finish displaying the page to the user first before executing them.

One approach I've heard here is u开发者_Python百科sing HTTPResponse::send() following the display. What approach is best/fastest here?

Note/Update: I'm done displaying everything by the time I'm starting doing these INSERT queries. This is a static page.


Use ob_implicit_flush(true);. It will send any data echo'd, immediately to the user's browser.

0

精彩评论

暂无评论...
验证码 换一张
取 消