Introduced:
The OB is the abbreviation for output buffering, and the buffer is controlled by the output_buffering variable in the php.ini. The default value is off, which can be set to on to open buffer. After hitting buffer, even if the program does not use the OB function, the code is actually using the buffer. In addition, PHP is always turned off by default in CLI mode, regardless of the output_buffering settings in php.ini. Why, what if the buffer zone? In short, the high-speed CPU processing their own data early, want to pass the line to the user, but the line is too narrow, the delivery is not over. If a buffer is introduced, the CPU can quickly put the generated data into a buffer, and then where it is cool where to stay and rest. Buffers output data in a timely manner according to the instructions. This kind of a reasonable solution to the high-speed CPU and low-speed I/O equipment contradictions.
Basic principles of Use:
If the OB cache is open, the echo data is first placed in the OB cache. If it is header information, put it directly in the program cache. When the page executes to the end, the data of the OB cache is placed in the program cache and returned to the browser in turn.
Basic methods of Use:
//Open OB Ob_start(); //output Some content, at this time the output of the content is not really output, but saved in the buffer Echo"Hello"; Echo"Word"; //getting data from a buffer $info=ob_get_contents(); //close and clear buffers Ob_end_clean(); Var_dump($info);//output: String ' Helloword ' (length=9)
PHP Buffer ob