使用ob_flush()前,确保前面的内容大小足够4069字符。一些Web服务器的output_buffering默认是4069字符或者更大,即输出内容必须达到4069字符服务器才会flush刷新输出缓冲,为了确保flush有效
php教程 ob_flush flush 输出缓存实例与说明
*/ ob_flush(); // flush(); // function flush (){ echo(str_repeat(' ',256)); // check that buffer is actually set before flushing if (ob_get_length()){ @ob_flush(); @flush(); @ob_end_flush(); } @ob_start(); }
//str_repeat(string,repeat) 把字符串重复指定的次数。
//实例二
@apache_setenv('no-gzip', 1);
@ini_set('zlib.output_compression', 0);
@ini_set('implicit_flush', 1);
for ($i = 0; $i ob_implicit_flush(1);
/*
使用注意事项:
flush和ob_flush的使用上有一些特别容易犯错的地方,造成无法刷新输出缓冲。
一. flush和ob_flush的正确顺序,正确应是,先ob_flush再flush,如下:
以下为引用的内容:
ob_flush();
flush();
如果web服务器的操作系统是windows系统,那顺序颠倒或者不使用ob_flush()也不会出现问题。但是在linux系统上就无法刷新输出缓冲。
二. 使用ob_flush()前,确保前面的内容大小足够4069字符。
一些web服务器的output_buffering默认是4069字符或者更大,即输出内容必须达到4069字符服务器才会flush刷新输出缓冲,为了确保flush有效
PHP怎么学习?PHP怎么入门?PHP在哪学?PHP怎么学才快?不用担心,这里为大家提供了PHP速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号