This example describes how to buffer and compress PHP dynamic content. PHP4 uses a buffer mechanism. Before you decide to send a message, all content is stored in the buffer, rather than directly sent to the browser, although you can use the header and setcookie functions to implement the buffer mechanism for PHP4, before you decide to send, all the content will only exist in the buffer, rather than directly sent to the browser, although you can use the header and setcookie functions, these two functions are just a bit of a "trick" compared to the powerful output functions ". Let's take a look at the true capabilities of these functions:
Void ob_start (void );
This function instructs the PHP processor to redirect all output to the internal buffer. after this function is called, no output will be made to the browser.
String ob_get_contents (void );
This function returns the output buffer to a string. you can send the accumulated output together to the browser. Of course, you must first turn off the buffer.
Int ob_get_length (void );
This function returns the length of the output buffer.
Void ob_end_clean (void );
This function clears and disables the buffer. You need to use this function before outputting data to the browser.
Void ob_implicit_flush ([int flag])
This function is used to control implicit buffering and purging. the default value is off. if it is enabled, the results of each print/echo or output command are sent to the browser.
II. Use output control to compress PHP output
Before you start, make sure that your PHP4 compilation supports Zlib.
First, initialize the output buffer:
The PHP output buffer function is very useful in script output operations. compressing the buffer can reduce the output time by 80%, which is used to access other data resources (such as databases or XML, it is also a good buffer mechanism.
Http://www.bkjia.com/PHPjc/629514.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/629514.htmlTechArticlePHP4 uses a buffer mechanism, before you decide to send, all content is only in the buffer, rather than directly sent to the browser, although you can use the header and setcookie function to implement...