php运行时输出,使用PHP中的实时输出运行进程

71339e2cfff6148fe6c3641ac0ce4e21.png

慕容大雪花

这是显示shell命令的实时输出的好方法:<?phpheader ("Content-type: text/plain");// tell php to automatically flush after every output// including lines of output produced by shell commandsdisable_ob();$command = 'rsync -avz /your/directory1 /your/directory2';system($command);您将需要此功能来防止输出缓冲:function disable_ob() {    // Turn off output buffering    ini_set('output_buffering', 'off');    // Turn off PHP output compression    ini_set('zlib.output_compression', false);    // Implicitly flush the buffer(s)    ini_set('implicit_flush', true);    ob_implicit_flush(true);    // Clear, and turn off output buffering    while (ob_get_level() > 0) {        // Get the curent level        $level = ob_get_level();        // End the buffering        ob_end_clean();        // If the current level has not changed, abort        if (ob_get_level() == $level) break;    }    // Disable apache output buffering/compression    if (function_exists('apache_setenv')) {        apache_setenv('no-gzip', '1');        apache_setenv('dont-vary', '1');    }}它不适用于我尝试过的每一台服务器,我希望我可以提供一些关于你在php配置中寻找什么的建议,以确定你是否应该试着让你的头发试图让这种行为发挥作用在你的服务器上!其他人都知道吗?这是普通PHP中的一个虚拟示例:<?phpheader ("Content-type: text/plain");disable_ob();for($i=0;$i<10;$i++) {    echo $i . "\n";    usleep(300000);}我希望这能帮助那些在谷歌上搜索的人。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值