I have a few conceptual questions (all related, I think) regarding the following script in the comments. The script works fine.
<?PHP ob_start(); // Create string to overflow browser buffer ...? $buffer = str_repeat(" ", 4096); // Indicate new header / html content ...? $buffer .= "\r\n<span></span>\r\n"; for ($i=0; $i<5; $i++) { echo $buffer.$i; ob_flush(); flush(); sleep(1); } ob_end_flush(); ?>
First, why should I send \r\n<tag>\r\n to the browser? I guess this has something to do with the headlines.
Secondly, why do I need HTML code in the middle?
Thirdly, there are many examples that use 256 bytes instead of 4096. However, the script does not work if I use 256. Are these examples obsolete and will this number change again in the future?
// CHANGE SOURCES OF SOURCES
This code was compiled mainly from the comment in the php.net sleep() function and the solution to this SO issue . It is not mentioned why include \r\n .
// EDIT FOR MANAGERS
If I do not add \r\n , the HTML tag and the second set \r\n , the script will not execute correctly in Chrome or Safari (it just unloads all the values ββat once).
In addition, if it is called before session_start() , it gives an error message: "Cannot send session cache limiters that have already been sent."
php header output-buffering
Ben Nov 16 '10 at 5:00 2010-11-16 05:00
source share