Reply to Unbuffer output in PHP

Your name:

Reply:


Posted by Bart Van der Donck on 05/20/06 12:40

Hello,

My Apache is configured so that it times out after ca. 2 and a half
minutes. For example, the following CGI script would have a time out
(because it runs longer than 2:30):

#!/usr/bin/perl
print "Content-Type: text/html\n\n";
for (0..1000) {
print "seconds running: $_<br>\n";
sleep 1;
}

But, if I add a line $|++ , Apache doesn't time-out:

#!/usr/bin/perl
print "Content-Type: text/html\n\n";
$|++;
for (0..1000) {
print "seconds running: $_<br>\n";
sleep 1;
}

$| (or $OUTPUT_AUTOFLUSH in full) is a special variable in Perl. It
makes the output of my CGI script unbuffered if its value is greater
than 0. This second script keeps outputting to the browser (unbuffered)
:

seconds running: 0
seconds running: 1
seconds running: 2
...
seconds running: 1000

Because Apache has "something to keep outputting" all the time, it
doesn't give a time-out here. Though in the first script, Apache waits
until the script has ended before output. Which thus triggers the
time-out and causes my script to end prematurely.

The problem I'm facing is that I have the same issue in PHP when
creating a large ZIP-file on-the-fly (more specifically in PhpMyAdmin's
export interface). I searched the PHP docs for "buffer" but none of
those functions seem to be suitable for what I want to do. Is this
possible in PHP ?

Thank you,

--
Bart

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация