Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/231.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 无脂肪框架刷新部分输出_Php_Fat Free Framework - Fatal编程技术网

Php 无脂肪框架刷新部分输出

Php 无脂肪框架刷新部分输出,php,fat-free-framework,Php,Fat Free Framework,我正在写一些后台网页来维护我们的系统。 我用的是F3 我有一条长流程的路线,分为许多子流程。 我为每个子流程制作了一个模板,如下所示: $f3->route('GET /someroute', function($f3) { dosomework(); echo template::instance()->render('template-job1.html'); dosomeotherwork(); echo template::instance()-&g

我正在写一些后台网页来维护我们的系统。 我用的是F3 我有一条长流程的路线,分为许多子流程。 我为每个子流程制作了一个模板,如下所示:

$f3->route('GET /someroute', function($f3) {
   dosomework();
   echo template::instance()->render('template-job1.html');

   dosomeotherwork();
   echo template::instance()->render('template-job2.html');
}
我希望我在浏览器中得到部分输出,因为它是准备好的(一次一个模板),但我得到的是我必须等待所有的输出

如果我尝试使用一个标准的php输出(例如,使用一些sleep()和一些echo()),我会一行一行地得到结果,而不是在过程结束时全部得到结果

f3的另一个示例:

$f3->route('GET /output', function($f3) {
    echo "pippo\n";

    for ($i=0;$i<100;$i++) {
        echo ".";
        sleep(1);
    }
});
$f3->route('GET/output',函数($f3){
回显“pippo\n”;

对于($i=0;$i),这是因为框架使用PHP的

因此,应首先禁用输出缓冲区并启用隐式输出刷新:

$f3->route('GET /output', function($f3) {

    // disable output buffering
    while (ob_get_level())
        ob_end_flush();

    // turn implicit flush
    ob_implicit_flush(1);

    // now every output call should be flushed instantly to the client
    for ($i=0;$i<10;$i++) {
        echo $i;
        sleep(1);
    }

});
$f3->route('GET/output',函数($f3){
//禁用输出缓冲
while(ob_get_level())
ob_end_flush();
//转隐式同花顺
ob_隐式_冲洗(1);
//现在,每个输出调用都应该立即刷新到客户端
对于($i=0;$i)
$f3->route('GET /output', function($f3) {

    // disable output buffering
    while (ob_get_level())
        ob_end_flush();

    // turn implicit flush
    ob_implicit_flush(1);

    // now every output call should be flushed instantly to the client
    for ($i=0;$i<10;$i++) {
        echo $i;
        sleep(1);
    }

});