PHP tutorial Seven kinds of cache control output instance code
Depending on whether the cache is open or not, there are several different ways to do this:
Note: The following code does not consider the IE cache must be greater than 256 bytes to output the problem, such as in IE test, please add a sentence in the code: "Echo str_repeat (", 256)
Writing 1:
Output_buffering = Off
Implicit_flush=off
For ($i =0 $i <10; $i + +) {
echo $i. ' <br/> ';
Flush ();
Sleep (1);
}
Writing 2:
Output_buffering = On
Implicit_flush=off
For ($i =0 $i <10; $i + +) {
echo $i. ' <br/> ';
Ob_flush ();
Flush ();
Sleep (1);
}
Writing 3:
Output_buffering = Off
Implicit_flush=off
Ob_start ();
For ($i =0 $i <10; $i + +) {
echo $i. ' <br/> ';
Ob_flush ();
Flush ();
Sleep (1);
}
Writing 4:
Output_buffering = On
Implicit_flush=off
Ob_end_flush ();
For ($i =0 $i <10; $i + +) {
echo $i. ' <br/> ';
Flush ();
Sleep (1);
}
Writing 5:
Output_buffering = On
Implicit_flush=off
Ob_end_clean ();
For ($i =0 $i <10; $i + +) {
echo $i. ' <br/> ';
Flush ();
Sleep (1);
}
Writing 6:
Output_buffering = on;
Implicit_flush=on
Ob_end_clean ();
or Ob_end_flush ();
For ($i =0 $i <10; $i + +) {
echo $i. ' <br/> ';
Sleep (1);
}
Writing 7:
Output_buffering = on;
Implicit_flush=on
Ob_end_clean ();
or Ob_end_flush ();
For ($i =0 $i <10; $i + +) {
echo $i. ' <br/> ';
Flush ();
Sleep (1);
}
Writing 8:
Output_buffering = Off
Implicit_flush=on
For ($i =0 $i <10; $i + +) {
echo $i. ' <br/> ';
Sleep (1);
}