PHP: Output buffer processing function Usage Summary

Source: Internet
Author: User
Tags php define
The output buffer handler function is a bit like the C stack, which is temporarily placed in a storage space to process the content.

The output buffer functions are:

    • Ob_start ()- open output control buffer

    • Ob_get_length ()-Returns the length of the output buffer

    • Ob_get_level ()-Returns the nesting level of the output buffer

    • Ob_get_status ()-Returns the state of the output buffer (returned as an array, returning the topmost layer by default, all when the parameter is true)

    • Ob_get_contents ()-Returns the contents of the output buffer

    • Ob_get_clean ()-Returns the current output buffer in string format and turns off output buffering

    • Ob_end_clean ()-Empty (erase) buffer and turn off output buffering

    • Ob_get_flush ()-Returns the output buffer content as a string and closes the buffer

    • Ob_end_flush ()-Flush out (send out) output buffer content buffer

Examples are as follows:

<?php define (' App_root ', DirName (FILE)); $file = '/templates/html/error_ Config.html ';  Ob_start (); Include (App_root. $file);   Ob_end_flush ();  $contents = Ob_get_contents ();   This allows the output to be saved for further processing//ob_end_clean (); echo $contents;? 
<?php echo "<?xml version=\" 1.0\ "encoding=\" utf-8\ ">";?> <! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd "> 

The output results are as follows:

Config.php does not exist or isn't readable by the webserver in the Phpsysinfo directory.

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.