Home >Backend Development >PHP Tutorial >基于flush()不能按顺序输出时的解决办法_PHP

基于flush()不能按顺序输出时的解决办法_PHP

WBOY
WBOYOriginal
2016-06-01 12:05:091042browse

如果是在linux下, 首先确认是否添加 ob_start() 和 ob_flush().
复制代码 代码如下:
ob_start();
for ($i=1; $i        echo $i."
\n";
        ob_flush();
        flush();
        usleep(500000);
}

如果还是不能输出的话, 就在代码前面加上头信息
复制代码 代码如下:
header("Content-Type:text/html;charset=utf8;");
ob_start();
for ($i=1; $i        echo $i."
\n";
       ob_flush();
    flush();
        usleep(500000);
}

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn