Questions tagged [output-buffering]

Use output-buffering for questions related to the use of one or more buffers in order to optimize performance by batching write operations

References

414 questions
29
votes
4 answers

PHP output buffering - sounds like a bad idea, is it?

Just want to pick the experts' brains on php output buffering. There are times when I've wanted to implement it for one reason or another, but have always managed to rearrange my code to get around it. I avoid using it because it sounds like…
Aaron
  • 329
  • 5
  • 9
22
votes
12 answers

Calling ob_flush() and flush(), yet browser doesn't show any output until script finishes

Hi Please View Below Code : \n"; for( $i = 0 ; $i < 10 ; $i++ ) { echo "$i
\n"; ob_flush(); flush(); sleep(1); } echo "End ...
\n"; ?> It's Incorrect ? i'm tested it but my output…
DJafari
  • 12,955
  • 8
  • 43
  • 65
22
votes
1 answer

Why doesn't print output show up immediately in the terminal when there is no newline at the end?

I have a python script that performs a simulation. It takes a fairly long, varying time to run through each iteration, so I print a . after each loop as a way to monitor how fast it runs and how far it went through the for statement as the script…
LWZ
  • 11,670
  • 22
  • 61
  • 79
22
votes
7 answers

How to flush data to browser but continue executing

I have a ob_start() and a corresponding ob_flush(). I would like to flush a portion of data and continue executing the rest. Using ob_flush() didn't help. Also if possible rest needs to happen without showing loading in browser. EDIT: I don't want…
aWebDeveloper
  • 36,687
  • 39
  • 170
  • 242
20
votes
2 answers

"headers already sent" Error returned during PHPUnit tests

I'm testing a suite of REST web services with PHPUnit. We're using output buffering in order to gzip-encode the responses. When I run a test for the service with PHPUnit, I'm getting the error: Cannot modify header information - headers already sent…
rhuff
  • 722
  • 2
  • 8
  • 14
18
votes
2 answers

what happened when i use multi ob_start() without ob_end_clean() or ob_end_flush()?

i have reviewed php manual about the ob_start() ob_end_clean() ob_end_flush(). And i have seen a different example about the subject, anyway i modified the example but i'm confused at this point. here is the script. ob_start(); echo "Hello x,…
Yunus Ekiz
  • 187
  • 1
  • 1
  • 9
15
votes
4 answers

How to determine whether ob_start(); has been called already

I use output buffering for gzip compression and access to what was put out before in a PHP script: if(!ob_start("ob_gzhandler")) ob_start(); Now if that script gets included in another script where ob_start() already is in use I get a…
C.O.
  • 2,281
  • 6
  • 28
  • 51
13
votes
2 answers

Assigning contents to a variable with include/require_once

Is it possible to do like $var = require_once('lol.php'); so that any HTML output that lol.php does will go inside $var? I know about output buffering, but is there some special built-in function that already does this?
Alex
  • 66,732
  • 177
  • 439
  • 641
13
votes
4 answers

Streaming output to a file and the browser

So, I'm looking for something more efficient than this: The problems with the above: Client doesn't receive anything…
Allain Lalonde
  • 91,574
  • 70
  • 187
  • 238
13
votes
8 answers

PHP Flush/ob_flush not working

I've tried several attempts at getting my flush and ob_flush to work. I've tried setting the ini to allow buffering, I've tried using several different functions I found online for output buffering, and none of it at all is working. The script wants…
JakeSmith
  • 131
  • 1
  • 1
  • 3
13
votes
1 answer

How do headers work with output buffering in PHP?

Title is self-explanatory. I have a good bit of experience with PHP, but I am not sure how the header function works between ob_start() and ob_end_clean(). Consider this: ob_start(); echo "Some content"; header('X-Example-Header: foo'); echo "Some…
Austin Hyde
  • 26,347
  • 28
  • 96
  • 129
11
votes
4 answers

Cannot use output buffering in output buffering display handlers

I've reinstalled Apache, and switched from PHP 5.3 to 5.6. Everything works, except I get this error, when calling ob_start(): Cannot use output buffering in output buffering display handlers I tried to enable output buffering in PHP, but I still…
Iter Ator
  • 8,226
  • 20
  • 73
  • 164
10
votes
4 answers

ob_flush takes long time to be executed

In my website(running with drupal) the ob_flush function takes a long time(between 10 - 100 secs) to be executed. How do I find out why? What can cause this so long time?
user16948
  • 4,801
  • 10
  • 30
  • 41
9
votes
3 answers

whats the difference between ob_flush and ob_end_flush?

i am confused about the PHP functions ob_flush() and ob_end_flush(). About the function ob_flush the manual says The buffer contents are discarded after ob_flush() is called.This function does not destroy the output buffer like ob_end_flush() does.…
lovesh
  • 5,235
  • 9
  • 62
  • 93
9
votes
2 answers

PHP Output buffering, Content Encoding Error caused by ob_gzhandler?

Can anyone explain why I am receiving the following error? In the code, if the echo $gz; is commented out I receive no error (but also no output!), if it isn't I get (from Firefox), Content Encoding Error The page you are trying to view cannot…
tjm
  • 7,500
  • 2
  • 32
  • 53
1
2
3
27 28