PHP:输出完成后继续 [英] PHP: continue after output is complete

查看:61
本文介绍了PHP:输出完成后继续的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

首先,我不是在寻找ignore_user_abort.相反,我寻找一个函数来完成输出并将文档发送给用户.之后,我希望 php 脚本执行额外的进程,这需要几秒钟,而不会对用户产生影响,只有后台进程.

First, I am not looking for ignore_user_abort. Instead, I look for a function to finalize the output and send the document to the user. After that, I'd like the php script to do additional process which takes another seconds without effects for the user, only background process.

用户也没有理由等待此操作完成.输出已经准备好迎头赶上.PHP 是否提供关闭与用户的连接的功能,但在服务器上保留一段时间以完成工作?

There is no reason for the user to wait for this to be completed, too. The output is ready for catch up before already. Does PHP provide a feature for closing the connection to the user, but remain for a while on the server to complete the work?

推荐答案

php-fpm 最好的特性之一就是 fastcgi_finish_requests().这将完成客户端的会话并在服务器端继续该过程.它也是消息传递的最佳用例,作为 cron 队列或延迟处理的替代方案.

One of the best features of php-fpm You is fastcgi_finish_requests(). This will finish the session for the client side and continue the process at serverside. It's also best use-case for messaging as an alternative for queque or delayed processing by cron.

但是,它仅限于 php-fpm!

However, it's restricted to php-fpm!

这篇关于PHP:输出完成后继续的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆