Urgent request: the test code for PHP real-time data output to the client is as follows: & lt ;? Phpob_start (); for ($ I = 1; $ I & lt; = 100; $ I ++) {& nbsp; $ sourceName = 'filetoupload '. $ I; & nbsp; urgent: questions about real-time PHP Data output to the client
The test code is as follows:
Ob_start ();
For ($ I = 1; $ I <= 100; $ I ++ ){
$ SourceName = 'filetoupload'. $ I;
$ ImageArray = array ();
$ Message = "Image $ I has been uploaded to the server ";
Echo $ message;
Flush ();
Ob_flush ();
Usleep (500000 );
}
Ob_end_flush ();
?>
The test results are as follows:
On the local server, the script can be run and output, but on the intranet server, the script is output after 100 cycles are run;
Expected results:
Like running results on a local server, the output is displayed while running. Why is the execution of the same script on an intranet server different? is it related to which configuration item in php. ini ??? Which configuration items are related ??? Thanks for your help.
------ Solution --------------------
If you are really anxious! I want to come up with a solution! That is, pass the value on the page. do not use a loop!
PHP code
$ Id = empty ($ _ GET ['id'])? 1: intval ($ _ GET ['id']); $ sourceName = 'filetoupload '. $ I; $ imageArray = array (); $ message = "Image $ I has been uploaded to the server"; echo $ message; if ($ id> = 100) {exit () ;}$ id ++; $ msg. ="
"; Echo $ msg; exit ();
------ Solution --------------------
For this problem, I started linux for a long time and didn't use it. I finally found that it was a cache problem.
PHP code
------ Solution --------------------
Discussion
Reference:
For this problem, I started linux for a long time and didn't use it. I finally found that it was a cache problem.
PHP code
Ob_start ();
For ($ I = 1; $ I <= 100; $ I ++ ){
Ob_end_flush (); // disable caching
$ SourceName = 'filetoupload'. $ I;
$ ImageArray = arr ......
------ Solution --------------------
This buffer is related to the browser and some modules of apache.
Keep try
==========================================
PHP code
Ob_end_clean (); apache_setenv ('no-gzip ', 1); ini_set ('zlib. output_compression ', 0); ini_set ('implicit _ flush', 1); ob_start (); // start buffering data for ($ I = 1; $ I <= 100; $ I ++) {$ sourceName = 'filetoupload '. $ I; $ imageArray = array (); $ message = "Image $ I has been uploaded to the server
"; Echo $ message. str_repeat (" ", 1024); // ie has the default 1 k buffer ob_flush (); flush (); usleep (500000 );}