Re: output buffering in CLI script.

From: Date: Thu, 28 Feb 2008 12:45:34 +0000
Subject: Re: output buffering in CLI script.
References: 1 2 3 4  Groups: php.general 
Request: Send a blank email to php-general+get-270549@lists.php.net to get a copy of this message
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>

« previous php.general (#270549) next »