About Ob_start (); How to fix it

Source: Internet
Author: User
About Ob_start ();
Want to ask Ob_start (); ob_get_contents (); Ob_end_clean ();
What is the use of these 3 functions and under what circumstances?

------Solution--------------------
The answer to the 03 weird corn

Introduction to the new function of PHP4-Output information control function
Demon Elves


These functions allow you to control the content of your script output. It can be used in many different situations, especially if your script has output information that requires a new file header to be sent. The output control function does not affect the header information sent with header () or Setcookie (), only those that are similar to The data blocks of Echo () and PHP code are useful.

Example 1. Control output


Ob_start ();
echo "hello\n";

Setcookie ("CookieName", "Cookiedata");

Ob_end_flush ();

?>

In the example above, the output using echo () will be saved in the output buffer until Ob_end_flush () is called. What makes sense is that the content of the call to Setcookie () is successfully stored in the cookie without causing an error. (Under normal circumstances, you can not send the file header information to the user's browser after the data has been sent.)

The associated function header () and Setcookie ().

List of Korean series
flush-Flush Output Buffers
The content that is saved in the output buffer is sent to the browser

ob_start-opening the output buffer
In this way, all output information is not sent directly to the browser, but is stored in the output buffer.

ob_get_contents-returns the contents of the output buffer
If you want to process the output later, you can call this function to keep a backup

ob_get_length-returns the content length of the output buffer

ob_end_flush-End (send) the contents of the output buffer, close the output buffer

ob_end_clean-Delete (Discard) The contents of the output buffer, close the output buffer
If your program finds a problem with the output, you can discard any output and prevent the disclosure of some secret information.

ob_implicit_flush-turn direct refresh on or off
Once opened, each script output is sent directly to the browser, eliminating the need to call flush (),
  • 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.