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
7
votes
5 answers

Use case for output buffering as the correct solution to "headers already sent"

I see (not just on this site) a lot of question from inexperienced PHP programmers about the infamous "headers already sent... output started at" error, and many people suggest using ouput buffering as a solution. In my experience I have never found…
Matteo Riva
  • 24,728
  • 12
  • 72
  • 104
7
votes
1 answer

If you flush the content (ob_flush) of an AJAX request, the content will get loaded?

I mean... Let's that we just make an AJAX request and inser the result inside a div#result.. In the backend the script use ob_flush() to send the header but not terminate the request until it's terminated (with exit or ob_flush_end) The content will…
Thiago Belem
  • 7,732
  • 5
  • 43
  • 64
7
votes
1 answer

Unbuffered CreateNamedPipe for use as stdout for CreateProcess

I would like to execute arbitrary command-line application and read its standard output as it gets produced. I use CreateNamedPipe to create a pipe and then supply other end (open used CreateFile) to CreateProcess. Provided the target process…
Oleg Zhylin
  • 1,290
  • 12
  • 18
7
votes
3 answers

Prevent output buffering with PHP and Apache

I have a PHP script which sends a large number of records, and I want to flush each record as soon as it is available: the client is able to process each record as it arrives, it does not need to wait for the entire response. I realize it takes…
brianmearns
  • 9,581
  • 10
  • 52
  • 79
7
votes
1 answer

How to configure ob_tidyhandler dynamically?

The PHP tidy extension has a function ob_tidyhandlerDocs that works with PHP output bufferingDocs as a callback, e.g.: ob_start('ob_tidyhandler'); I know that Tidy has a lot of configuration settingsDocs, however I am hitting a road block to setup…
hakre
  • 193,403
  • 52
  • 435
  • 836
6
votes
3 answers

Perl: Reading from a 'tail -f' pipe via STDIN

There were a number of other threads like this, but the usual conclusion was something like "Install File::Tail". But, I'm on an old box that we're decomissioning, and I just want to write a one-liner to monitor a log. I tried installing…
coding_hero
  • 1,759
  • 3
  • 19
  • 34
6
votes
1 answer

Phpunit, test code or tested code did not (only) close its own output buffers

I have a code to test: class ToTest { public function testMe() { echo 'test'; } } class TestTest extends \PHPUnit\Framework\TestCase { public function testX() { ob_start(); (new ToTest())->testMe(); …
John Smith
  • 6,129
  • 12
  • 68
  • 123
6
votes
2 answers

session_regenerate_id() - headers already sent in unit testing Yii controller

I'm trying to unit-test my controller (Yii framework). /** * @dataProvider provider */ public function testActionEdit_view_login($controller){ $user = new CWebUser; $user->id = 978; $identity = new UserIdentity('me@test.com',…
MrB
  • 2,155
  • 7
  • 27
  • 33
6
votes
3 answers

PHP - htaccess - output_buffering

I have the following code in an htaccess file in my application root to turn output buffering on. php_value output_buffering On php_value output_handler mb_output_handler On some servers it causes a 500 internal error, on others it works fine. Does…
anon445699
6
votes
4 answers

Is there a way to make PHP progressively output as the script executes?

So I'm writing a disposable script for my own personal single use and I want to be able see how the process is going. Basically I'm processing a couple of thousand media releases and sending them to our new CMS. So I don't hammer the CMS, I'm making…
Iain Fraser
  • 6,578
  • 8
  • 43
  • 68
6
votes
3 answers

Disable output buffering on my local XAMPP server

For some reason my XAMPP server is buffering the output of my PHP. I want it to spit it out as it goes. Anyone any ideas which settings I need to change to achieve this?
Mark
  • 5,423
  • 11
  • 47
  • 62
6
votes
2 answers

Output buffering vs. storing content into variable in PHP

I don't know exactly how output buffering works but as far as know it stores content into some internal variable. Regarding this, what is the difference of not using output buffering and storing content in my own local variable instead and than…
Borut Tomazin
  • 8,041
  • 11
  • 78
  • 91
5
votes
4 answers

Cookies are Not Being Set Properly in PHP Script

Im very new in php and try to use cookie but it is not woking in my site, can anyone guide me please , what is going wrong in my code:
jbcedge
  • 18,965
  • 28
  • 68
  • 89
5
votes
5 answers

get return from echo

I'm working with some functions that echo output. But I need their return so I can use them in PHP. This works (seemingly without a hitch) but I wonder, is there a better way? function getEcho( $function ) { $getEcho = ''; …
ryanve
  • 50,076
  • 30
  • 102
  • 137
5
votes
1 answer

CodeIgniter - Editing Output Buffer before sent to browser?

I'm researching the PHP framework CodeIgniter. I need some help regarding editing the output before it's flushed to the user. Usually in PHP, you can just use ob_start(); and then ob_get_clean(); to retrieve the contents. While reading the…
SoreThumb
  • 530
  • 1
  • 5
  • 17