Home > Backend Development > PHP Tutorial > php ob_flush flush output cache examples and instructions_PHP tutorial

php ob_flush flush output cache examples and instructions_PHP tutorial

WBOY
Release: 2016-07-20 11:01:57
Original
1117 people have browsed it

Before using ob_flush(), make sure that the previous content size is enough to 4069 characters. The default output_buffering of some web servers is 4069 characters or larger, that is, the output content must reach 4069 characters before the server flushes the output buffer. In order to ensure that the flush is effective ​

php tutorial ob_flush flush output caching examples and instructions

*/
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) Repeat the string the specified number of times.

//Example 2

@apache_setenv('no-gzip', 1);

@ini_set('zlib.output_compression', 0);
@ini_set('implicit_flush', 1);
for ($i = 0; $i < ob_get_level(); $i++) { ob_end_flush(); }
ob_implicit_flush(1);

/*
Precautions for use:
There are some particularly easy mistakes in the use of flush and ob_flush, resulting in the failure to flush the output buffer.

1. The correct order of flush and ob_flush, the correct order should be, ob_flush first and then flush, as follows:

The following is the quoted content:

ob_flush();
flush();
If the operating system of the web server is a windows system, there will be no problem if the order is reversed or ob_flush() is not used. But on Linux systems, the output buffer cannot be flushed.

2. Before using ob_flush(), ensure that the previous content size is enough to 4069 characters.

The default output_buffering of some web servers is 4069 characters or larger, that is, the output content must reach 4069 characters before the server flushes the output buffer. In order to ensure that the flush is effective


http://www.bkjia.com/PHPjc/445393.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/445393.htmlTechArticleBefore using ob_flush(), make sure that the previous content size is enough for 4069 characters. The default output_buffering of some web servers is 4069 characters or larger, that is, the output content must reach 4069 characters server...
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