PHP Output Control

Source: Internet
Author: User
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_bufferingDefault0You can set a value to open the output buffer and limit the buffer size.
  • output_handler, DefaultNULLThis option redirects all the output of the script to a function.
  • implicit_flush, Default0The 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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.