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

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

WBOY
Release: 2016-06-01 12:05:09
Original
1059 people have browsed it

如果是在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);
}

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template