Home >Backend Development >PHP Tutorial >php ob_flush flush output cache examples and instructions_PHP tutorial
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.
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