非swoole的方式实现简单的异步(nginx模式下)
set_time_limit(0);
echo '任务开始'.time();/*即时打印*/
register_shutdown_function([$this, "test"]);/*异步执行 test 为类中方法名 */
echo '任务结束'.time();/*即时打印*/
fastcgi_finish_request();
exit;
注: 这种方式只适合nginx服务下且业务量比较小的需求, 主要方法是fastcgi_finish_request()
If the copyright belongs to the longfei, please indicate the source!!!