Home > Article > Backend Development > Several examples commonly used in php buffering technology_PHP tutorial
//Initialize session
session_start();
//Add the value of url rewrite
output_add_rewrite_var('var','value');
//Insert a connection
echo 'link';
//Send buffer data
ob_flush();
//Reset the value of url rewrite
output_reset_rewrite_vars();
//Insert a connection
echo 'link';
/*
*/
print_r(ob_list_handlers()); //List the output handlers used, and the default output handler
will be output ob_end_flush(); //Send buffer data and close the buffer
ob_start("ob_gzhandler"); //Open the buffer and use ob_gzhandler
print_r(ob_list_handlers()); //List the output handles, ob_gzhandler
will be output ob_end_flush(); //Send buffer data and close the buffer
ob_start(create_function('$string','return $string;')); //Open buffer
print_r(ob_list_handlers()); //List the output handlers used, and the default output handler
will be output ob_end_flush(); //Send buffer data and close the buffer
/*
*/
if(ob_get_level()==0) //Determine the buffer level, if there is no active buffer
ob_start(); //Open buffer
for($i=0;$i<10;$i++) //Loop execution operation
{
echo "
line to show."; //Output content
echo str_pad('',4096)."n"; //Output the generated string
ob_flush(); //Send buffer data
flush(); //Refresh the buffer
sleep(1); //Pause for 1 second
}
echo "done."; //Output operation completion mark
ob_end_flush(); //Send buffer data and close the buffer
?>