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
1573
votes
13 answers

How can I flush the output of the print function?

How do I force Python's print function to flush the buffered output to the screen? See also: Disable output buffering if the goal is to change the buffering behaviour generally. This question is about explicitly flushing output after a specific…
Walter Nissen
  • 16,451
  • 4
  • 26
  • 27
660
votes
16 answers

Disable output buffering

Is output buffering enabled by default in Python's interpreter for sys.stdout? If the answer is positive, what are all the ways to disable it? Suggestions so far: Use the -u command line switch Wrap sys.stdout in an object that flushes after every…
Eli Bendersky
  • 263,248
  • 89
  • 350
  • 412
350
votes
10 answers

What's the use of ob_start() in php?

Is ob_start() used for output buffering so that the headers are buffered and not sent to the browser? Am I making sense here? If not then why should we use ob_start()?
Aditya Shukla
  • 13,595
  • 12
  • 38
  • 36
230
votes
8 answers

What is output buffering in PHP?

What is output buffering and why would you use it in PHP?
Abhimanyu
  • 4,752
  • 7
  • 33
  • 44
177
votes
4 answers

What exactly is file.flush() doing?

I found this in the Python documentation for File Objects: flush() does not necessarily write the file’s data to disk. Use flush() followed by os.fsync() to ensure this behavior. So my question is: what exactly is Python's flush doing? I thought…
geek
  • 2,677
  • 4
  • 23
  • 21
109
votes
8 answers

Test PHP headers with PHPUnit

I'm trying to use PHPunit to test a class that outputs some custom headers. The problem is that on my machine this:
titel
  • 3,454
  • 9
  • 45
  • 54
83
votes
4 answers

PHP buffer ob_flush() vs. flush()

What's the difference between ob_flush() and flush() and why must I call both? The ob_flush() reference says: This function will send the contents of the output buffer (if any). The flush() reference says: Flushes the write buffers of PHP and…
Ben
  • 54,723
  • 49
  • 178
  • 224
61
votes
5 answers

How to clear previously echoed items in PHP

In php, is there any way to clear/remove all previously echoed or printed items? For example:
edt
  • 22,010
  • 30
  • 83
  • 118
43
votes
4 answers

Difference between ob_get_clean and ob_get_flush

They both seem to do the same thing: return the output buffer content to you and delete it aftewards. Which one should I use?
EEka
  • 443
  • 1
  • 4
  • 4
42
votes
2 answers

Difference between ob_clean and ob_flush?

What's the difference between ob_clean() and ob_flush()? Also what's the difference between ob_end_clean() and ob_end_flush()? I know ob_get_clean() and ob_get_flush() both get the contents and end output buffering.
Alex V
  • 18,176
  • 5
  • 36
  • 35
41
votes
2 answers

Node echo server degrades 10x when stream pipes are used over buffering

On node v8.1.4 and v6.11.1 I started out with the following echo server implementation, which I will refer to as pipe.js or pipe. const http = require('http'); const handler = (req, res) =>…
Nick Babcock
  • 6,111
  • 3
  • 27
  • 43
39
votes
4 answers

PHP: Suppress output within a function?

What is the simplest way to suppress any output a function might produce? Say I have this: function testFunc() { echo 'Testing'; return true; } And I want to call testFunc() and get its return value without "Testing" showing up in the page.…
Wilco
  • 32,754
  • 49
  • 128
  • 160
33
votes
6 answers

Get content between two strings PHP

Whats is the best way to obtain the content between two strings e.g. ob_start(); include('externalfile.html'); ## see below $out = ob_get_contents(); ob_end_clean(); preg_match('/{FINDME}(.|\n*)+{\/FINDME}/',$out,$matches); $match =…
Lizard
  • 43,732
  • 39
  • 106
  • 167
30
votes
8 answers

Is using output buffering considered a bad practice?

Are ob_start / ob_get_clean() considered bad practice by php programmers in general? Are there any disadvantages of output buffering?
Alex
  • 66,732
  • 177
  • 439
  • 641
29
votes
7 answers

HTML into PHP Variable (HTML outside PHP code)

I am new to php and wondering if I can have something like this: ... ... What I have to use right now is
Maksim Vi.
  • 9,107
  • 12
  • 59
  • 85
1
2 3
27 28