Buffer output instance code in php

Source: Internet
Author: User

Ob_start ([string output_callback])-open the output buffer
All output information is not directly sent to the browser, but saved in the output buffer. An optional callback function is used to process output result information.
Ob_end_flush-end (send) output buffer content, disable the output buffer

*/

Ob_start (); // open the buffer
Echo "hello world"; // output content
$ Out = ob_get_clean (); // obtain the buffer content and end the buffer.
$ Out = strtolower ($ out); // converts a character to lowercase.
Var_dump ($ out); // output result

//

If (! Function_exists ('ob _ clean') // checks whether the function is defined.
{
Function ob_clean () // define a function
{
If (@ ob_end_clean ())
{
Return ob_start ();
}
Trigger_error ("ob_clean () failed to delete buffer. no buffer to delete.", e_user_notice );
Return false;
}
}

//

Header ('content-type: multipart/x-mixed-replace; boundary = endofsection '); // send the header
Print "n -- endofsectionn"; // output content
$ Pmt = array ("-", "", "|", "/"); // defines an array
For ($ I = 0; $ I <10; $ I ++) // perform operations through Loops
{
Sleep (1); // pause execution
Print "content-type: text/plainnn"; // output content
Print "part $ it". $ pmt [$ I % 4]; // output content
Print "-- endofsectionn"; // output content
Ob_flush (); // sends the buffer data
Flush (); // refresh the output buffer
}
Print "content-type: text/plainnn"; // output content
Print "the endn"; // output content
Print "-- endofsection -- n"; // output content


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.