Teach you how to use the PHP function flush () correctly (). For the content just learned 1. Flush: refresh the buffer and output. Function format: flush () is a very efficient function in PHP3, which has a very
1. Flush: refresh the buffer content and output it.
Function format: flush ()
This function appears in PHP3. it is a very efficient function. a very useful function is to refresh the browser cache. let's take an example with very obvious running effect to illustrate the PHP function flush ().
Example 2.
- <? Php
- For ($ I = 1; $ I <= 300; $ I ++) print ("");
- // This sentence is critical, and the cache structure
So that its content can be output from the browser only when it reaches a certain size
- // In other words, if the cache content does not reach
It is not output before the program is executed. Jing
- // After testing, I found that the limit of this size is
256 characters long. This means that all content received by the cache will be
- // Continuously sent out.
- For ($ j = 1; $ j <= 20; $ j ++ ){
- Echo $ j ."
- ";
- Flush (); // This part will add content to the cache.
Squeezed out and displayed on the browser
- Sleep (1); // let the program "sleep" for one second, it will
You can see the effect more clearly.
- }
- ?>
PHP2000's latest PHP chat room uses this technology. Unfortunately, the source code is not publicly available. Note: If ob_implicit_flush () is added to the program header to enable absolute refresh, you can stop using the PHP function flush () in the program. The advantage of doing so is to improve efficiency!
Tip 1. Flush: refresh the buffer content and output it. Function format: flush () this function appears in PHP3. it is a very efficient function and has a very...