When PHP scripts have output, the output control function can use these to control the output. This is useful in many different situations, especially when the script starts to output data, it sends the http header information to the browser. The output control function does not affect the header information sent by the header () or setcookie (), but only affects
When PHP scripts have output, the output control function can use these to control the output. This is useful in many different situations, especially when the script starts to output data, it sends the http header information to the browser. The output control function does not affect the header information sent by the header () or setcookie (), but only affects
When PHP scripts have output, the output control function can use these to control the output. This is useful in many different situations, especially when the script starts to output data, it sends the http header information to the browser.
The output control function does not affect the header information sent by the header () or setcookie (). It only affects data between functions such as echo and PHP code blocks.
Zookeeper PHP output control is extended as part of the PHP core and requires no additional installation, but there are some parameters in php. ini to configure it. Of course, you can also useini_set()
To implement runtime control.
Output Control Configuration Options
output_buffering
Default0
You can set a value to open the output buffer and limit the buffer size.
output_handler
, DefaultNULL
This option redirects all the output of the script to a function.
implicit_flush
, Default0
The default value is FALSE. If this option is changed to TRUE, PHP will make the output layer automatically Refresh after each segment of information block is output. This is equivalent to callingflush()
Function.
Output Control Function
- Flush-refresh the output buffer
- Ob_clean-clear (erase) output buffer
- Ob_end_clean-clear (erase) the buffer and disable the output buffer.
- Ob_end_flush-extracts (sends) the output buffer content and closes the buffer.
- Ob_flush-extract (send) the content in the output buffer
- Ob_get_clean-get the content of the current buffer and delete the current output.
- Ob_get_contents-return the content of the output buffer
- Ob_get_flush-clears (sends) the buffer content, returns the content in string format, and closes the output buffer.
- Ob_get_length-return the length of the output buffer content
- Ob_get_level-nesting level of the returned output buffer mechanism
- Ob_get_status-obtains the status of all output buffers.
- Ob_gzhandler-the callback function used in ob_start to compress the content in the output buffer. Ob_start callback function to gzip output buffer
- Ob_implicit_flush-enable/disable absolute fl
- Ob_list_handlers-list all output handlers in use.
- Ob_start-enable the Output Control Buffer
- Output_add_rewrite_var-Add URL rewriter values)
- Output_reset_rewrite_vars-Reset the value of the URL rewrite (Reset URL rewriter values)
Example
ob_start();echo 'aaa';$string = ob_get_contents();file_put_contents('a.html', $string);ob_flush();flush();
Original article address: PHP output control, thanks to the original author for sharing.