Andrés Robinet schreef:
-----Original Message-----
From: Jochem Maas [mailto:jochem@xxxxxxxxxxxxx]
Sent: Thursday, February 28, 2008 6:39 AM
To: [php] PHP General List
Subject: output buffering in CLI script.
hi there,
I can't seem to manage to buffer output (of an included file) in a CLI
script,
the following does not work:
// buffer output so we can avoid the shebang line
being output (and strip it from the output we log)
$oldIFvalue = ini_set('implicit_flush', false);
ob_start();
if (!@include $script) {
ob_end_clean();
} else {
$output = explode("\n", ob_get_clean());
if ($output[0] && preg_match('%^#!\/%',
$output[0]))
unset($output[0]);
}
ini_set('implicit_flush', $oldIFvalue);
the reason I'm wanting to do this is, primarily, in order to stop the
shebang line that *may*
be present in the included script from being output to stdout.
--
Aren't you deleting the output when you do ob_get_clean?
Meaning, you are missing an echo of the captured buffer, like:
$output = explode("\n", ob_get_clean());
if ($output[0] && preg_match('%^#!\/%', $output[0]))
unset($output[0]);
echo join("\n", $output); // You need to echo this, since you lost your buffer
by doing ob_get_clean
I'm retrieving the output buffer and shoving it in $output - which is
subsequently logged to a file. but output is not being buffered at all regardless
of implicit_flush setting and/or use of ob_start()
:-(
Regards,
Rob
Andrés Robinet | Lead Developer | BESTPLACE CORPORATION
5100 Bayview Drive 206, Royal Lauderdale Landings, Fort Lauderdale, FL 33308 |
TEL 954-607-4207 | FAX 954-337-2695 |
Email: info@xxxxxxxxxxxxx | MSN Chat: best@xxxxxxxxxxxxx | SKYPE: bestplace |
Web: bestplace.biz | Web: seo-diy.com
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php