首页 > Web开发 > 详细

php 执行耗时任务 后台执行

时间:2018-09-26 15:54:10      阅读:173      评论:0      收藏:0      [点我收藏+]
// 你要跳转的url
$url = "http://www.baidu.com/";
 
// 如果使用的是php-fpm
if(function_exists(‘fastcgi_finish_request‘)){
    header("Location: $url");
    ob_flush();
    flush();
    fastcgi_finish_request();
// Apache ?
}else{
    header( ‘Content-type: text/html; charset=utf-8‘ );
    if(function_exists(‘apache_setenv‘))apache_setenv(‘no-gzip‘, ‘1‘);
    ini_set(‘zlib.output_compression‘, 0);
    ini_set(‘implicit_flush‘, 1);
    echo "<script>location=‘$url‘</script>";
    ob_flush();
    flush();
}
 
    // 这里是模拟你的耗时逻辑
    sleep(33);

linux测试成功,windows不行

可处理的扩展 Gearman yii2-queue exec命令等 待研究

 

php 执行耗时任务 后台执行

原文:https://www.cnblogs.com/jimz/p/9707001.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!