Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to get line-by-line output

Status
Not open for further replies.

pcorchary

MIS
Feb 23, 2002
60
US
I'll FREELY admit I'm a newbie, and only a hacker-programmer. With that out of the way...

I have a script that needs to iterate through a series of (33) steps, each taking 2-5 seconds.

I've written this as a BASH CGI that outputs CSS/HTML, and it pushes one line of output per iteration to the browser, which is what I want, giving good feedback during the 1-2 total minutes of execution.

I'm trying to write this in PHP4, and it builds all of the output in buffer and dumps it all at once to the browser. Yuck. This is horrible ...

How can I change this behaviour in PHP? Certainly PHP can't be limited this way ... This seems like such a simple thing but I've spent hours googling and checking php tutorials and books!.

Thank in advance.
 
PHP (and other server-side script processors working with http requests) does not control output. It's HTTP server task. Moreover, it's user browser task to render and to display http stream on the screen. Therefore, it's impossible to synchronize PHP script control flow and http user screen in principle.
May be flush() helps (to some degree;) but the key point here: browser is NOT PHP console...
 
What is different then about the output model of CGI (written in bash shell), from php then ... because CGI works perfectly on the output side...
 
I've tried using
flush ();
ob_flush ();

in my loop, and the correct results occur on Firefox, but not on IE. (Naturally, right ;-). Perhaps because I'm in a table when writing HTML - i'll try no table.

Anyway, I understand that display model of web apps -- it's still a puzzlement to me that the CGI works in all cases, all browsers, etc, and php doesn't :-(
 
Yes, if you are in a table when flushing, it will not print, IE waits till it sees the entire table before rendering..
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top