RE: [PHP] Delaying Printed Output

From: Date: Mon, 26 Mar 2001 04:44:08 +0000
Subject: RE: [PHP] Delaying Printed Output
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-45572@lists.php.net to get a copy of this message
This topic comes up from time to time... Some previous information, if you get any further please post it to the list. A while ago I saw a web page explaining a system (written in Perl I think) that was used to show a presentation to a number of different sites simultaneously (and synchronised). A presenter was at the main site and the browsers at 4 other remote sites would display the same page the presenter was viewing on his web browser as he went to various sites. I think it worked using multipart Content-type. Unfortunately I have lost the URL to the explanation of how it was done. On Saturday, 5 August 2000 8:48 AM Mr Bruce Christensen posted the following links explaining browser push; http://home.netscape.com/assist/net_sites/pushpull.html and; As for keeping the connection from timing out, see http://www.php.net/manual/function.set-time-limit.php. I have experimented with this but didn't get too far. I posted the following to the PHP list but didn't get any reply. I have tried the following script on WinNT5, Apache/1.3.13-dev, PHP Version 4.0.1pl2 and OpenBSD2.7 Apache/1.3.12, PHP Version 4.0.1pl2 (mod_php4) push.php; ----------8<-------snip-----------8<------start <?php header("HTTP/1.0 200 OK"); header("Content-type: multipart/x-mixed-replace;boundary=ThisRandomString"); print("\n"); print( "--ThisRandomString\n"); print("Content-type: text/html\n"); print("\n"); print( "First update at "); echo date("H:i:s"); print("\n\n"); print( "--ThisRandomString\n"); flush(); sleep(5); print("Content-type: text/html\n"); print("\n"); print( "Second update at "); echo date("H:i:s"); print("\n\n"); print("--ThisRandomString--\n"); ?> ----------8<-------snip-----------8<------end On NT with the header("HTTP/1.0 200 OK"); statement I get an Apache error message; [Sun Aug 06 09:02:47 2000] [error] [client 192.168.0.60] malformed header from script. Bad header=HTTP/1.0 200 OK: f:/program files /novato/allcnet/php.exe I do not get this error on OpenBSD. I then removed the header("HTTP/1.0 200 OK"); statement and now NT and OpenBSD give the following output to the browser(IE5.0); (after a 5 second pause) ----------8<-------snip-----------8<------start --ThisRandomString Content-type: text/html First update at 18:22:47 --ThisRandomString Content-type: text/html Second update at 18:22:52 --ThisRandomString ----------8<-------snip-----------8<------end And the following output to the browser(Netscape 4.6); (after a 5 second pause) ----------8<-------snip-----------8<------start Second update at 18:23:19 ----------8<-------snip-----------8<------end ie With Netscape I never see the first update at ... part of the output as I would expect. I have also tried it with; header("Content-type: multipart/mixed;boundary=ThisRandomString"); but it makes no difference, the behaviour is identical. IE5 does not seem to understand multipart. The multipart mime boundary does not seem to be working properly in Netscape4.6. Regards Andrew Braund > -----Original Message----- > From: Greg Scott [mailto:gscott@tds.net] > Sent: Sunday, 25 March 2001 04:49 > To: php-general@lists.php.net > Subject: Re: [PHP] Delaying Printed Output > > > > You might try using flush() after the prints. > > > I tried that too, but at least in Netscape 6, it still waits until > everything is done before displaying. I think Jack must be correct that > this isn't possible for browser display. > > Thanks, > Greg

« previous php.general (#45572) next »