Jump to content

No output buffering problem


mrbrdo

Recommended Posts

Hey, i'm trying the following:

<?php
echo "x";
sleep(5);
echo "y";
?>

I would expect this to echo x, then after 5 seconds echo y. What it does is echo xy after 5 seconds. I tried many things to disable buffered output, like setting ob_implicit_flush(1);, ob_end_flush(); and even calling flush(); after the echo, but in any case all content gets displayed at one time and not x first, y after 5 seconds.

 

Thank you

Link to comment
https://forums.phpfreaks.com/topic/42826-no-output-buffering-problem/
Share on other sites

That's not true at all. PERL is server-side too, but it has the capability to do this. Also, what's the point of BUFFERED OUTPUT if not that it buffers the output before actually outputting it.. So if you disable that, you should be getting the page displayed as it's possible. You guys got the terms of server-side scripting mixed up. And no, i don't want javascript, it has nothing to do with what i'm doing.

 

In perl you can do this easily by putitng "$| = 1; " in your script, as stated here: http://www.wellho.net/forum/Perl-Programming/Gradual-output-from-cgi-script.html

In PHP disabling buffered output or enabling implicit flush should be doing the same thing, but it's just not working.

I appreciate your comments but if you are not familiar with how buffered output works, you might not want to try and help here.

You might have noticed UNbuffered output somewhere with chat CGI scripts, where it always says Transferring from www.xxx.com... in your browser... that's basically what i need, i just won't feed the data indefinitely like the chat scripts do, i just want to echo something, process something that takes time, and echo something again.

 

frost110 no, that does not work

 

Thanks

Doesn't work for me.. Is it possible there is an Apache module that's doing buffering on it's own? I'm using Apache 2.2.3 on FreeBSD.

I can't see any module that could be a problem though, i do have mod_deflate but it's not configured to be enabled for the site where i'm trying this...

It could be a server issue though, because when i run on the command line with "php test.php" it works correctly, but when opening it as a web page it does not work correctly (outputs everything at once).

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.