PHP Buffered output Instance Code _php tutorial

Source: Internet
Author: User
Ob_start ([string output_callback])-Open output buffer
All output information is not sent directly to the browser, but is stored in the output buffer, the optional callback function is used to process the output information.
Ob_end_flush-End (send) the contents of the output buffer, close the output buffer

*/

Ob_start ();//Open buffer
echo "Hello World"; Output content
$out =ob_get_clean (); Get buffer contents and end buffer
$out =strtolower ($out); Convert a character to lowercase
Var_dump ($out); Output Results

//

if (!function_exists (' Ob_clean '))//Determine if the function is defined
{
function Ob_clean ()//define Functions
{
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 headers
print "N--endofsectionn"; Output content
$PMT =array ("-", "" "," | ","/"); Defining arrays
for ($i =0; $i <10; $i + +)//operation via loop
{
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 (); Send buffer data
Flush (); Refresh output buffering
}
print "content-type:text/plainnn"; Output content
Print "The Endn"; Output content
print "--endofsection--n"; Output content


http://www.bkjia.com/PHPjc/444811.html www.bkjia.com true http://www.bkjia.com/PHPjc/444811.html techarticle Ob_start ([string output_callback])-Open output buffer All output information is not sent directly to the browser, but is saved in the output buffer, the optional callback function is used to ...

  • 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.