PHP buffered output instance analysis, PHP buffer instance analysis
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, 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
The instance code is as follows:
Copy CodeThe code is as follows: 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
I hope this article is helpful to everyone's PHP programming.
http://www.bkjia.com/PHPjc/937724.html www.bkjia.com true http://www.bkjia.com/PHPjc/937724.html techarticle PHP Buffered output instance analysis, PHP buffer Instance Analysis This article describes the PHP buffered output usage. Share to everyone for your reference. The specific analysis is as follows: Ob_start ([string Output_ca ...