Urgent request: About PHP Real-time output data to the client related issues

Source: Internet
Author: User
Tags usleep
Urgent request: About PHP Real-time output data to the client.
The test code is as follows:
Ob_start ();
for ($i = 1; $i <=; $i + +) {
$sourceName = ' filetoupload '. $i;
$imageArray = Array ();
$message = "Image $i have 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 run side output, but in the intranet server running is 100 cycles after the run-time output;

Desired correct result:
As the results are running on the local server, the side runs the output display. Why the same script in the network server execution is a different result, is not related to which configuration item in PHP.ini??? What configuration items are associated with??? Hope to get everyone's help, thank you first.


------Solution--------------------
If you're really in a hurry! I think of a way! is the page transfer value, do not use the 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--------------------
I've been working on this for a long time. Linux final discovery is a cache problem
PHP Code
    
------Solution--------------------
discuss
Reference:
I've been working on this for a long time. Linux final discovery is a cache problem

PHP Code

Ob_start ();
for ($i = 1; $i <=; $i + +) {
Ob_end_flush ();//Close cache
$sourceName = ' filetoupload '. $i;
$imageArray = arr ...

------Solution--------------------
This buffer is related to the browser, and some of the Apache modules are also relevant.
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 buffer data for ($i = 1; $i <=, $i + +) {$source Name = ' filetoupload '.    $i;    $imageArray = Array ();    $message = "Image $i have been uploaded to the server 
"; echo $message. Str_repeat ("", 1024x768);//ie has the default 1k buffer Ob_flush (); Flush (); Usleep (500000);}
  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.