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…
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…
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…
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…
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…
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…
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();
…
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',…
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…
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…
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?
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…
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 = '';
…
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…