Re: output buffering in CLI script.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Jochem Maas wrote:
I mean that the shebang line at the top of the included file is output
to stdout even when I turn on output buffering on prior to including the file.

nothing else is output but that's because the script doesn't generate any further output - it logs everything instead - and I know it runs because the relevant lines appear in the relevant log file.


I don't know what goes wrong here. I took your script and it just works, so it is not your code (I guess).

I've done this:

$oldIFvalue = ini_set('implicit_flush', false);

ob_start();

if (!include 'scrap2.php') {

   ob_end_clean();
}
else {

   $output = explode("\n", ob_get_clean());

   if ($output[0] && preg_match('%^#!%', $output[0]))
       unset($output[0]);

   echo implode("\n", $output);
}

ini_set('implicit_flush', $oldIFvalue);

The only difference is it echoes imploded $output. And I do a bit different preg_match ^#! instead of ^#!\/

If you can include the script you want to include, than it should work.
If you can buffer output without the include file, than it should work.
If you can dump $output after you've done the explode, than it should work.

So, I don't know what goes wrong.


--
Aschwin Wesselius

<social>

What you would like to be done to you, do that to the other....

</social>

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux