This example describes the PHP buffered output usage. Share to everyone for your reference. The specific analysis is as follows:
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, which is used to process output information.
Ob_end_flush-End (send) the contents of the output buffer, turn off the output buffer
The instance code is as follows:
Copy Code code as follows:
Ob_start (); Open buffer
echo "Hello World"; Output content
$out =ob_get_clean (); Gets the buffer contents and ends the buffer
$out =strtolower ($out); Convert a character to lowercase
Var_dump ($out); Output results
//
if (!function_exists (' Ob_clean '))//Determine whether the function is defined
{
function Ob_clean ()//defining 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 + +) to operate by looping
{
Sleep (1); Suspend 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 (); Refreshing output buffers
}
print "content-type:text/plainnn"; Output content
Print "The Endn"; Output content
print "--endofsection--n"; Output content
I hope this article will help you with your PHP program design.