Hi, i've got a php script that runs on the command line. To improve it's performance, i would like to completely suppress it's output.
How can I do that?
Thanks!
Hi, i've got a php script that runs on the command line. To improve it's performance, i would like to completely suppress it's output.
How can I do that?
Thanks!
function ob_esity($b) { return ''; }
ob_start('ob_esity');
Not sure about performance but you can use
php -q myscript.php > /dev/null
One way would be to call ob_start() to turn on output buffering, and periodically call ob_clean() if you really don't want the output (or use a dummy ob_start() callback which does nothing).
Not sure how much of a performance gain this would be, as internally, PHP is still processing the output, except it goes into a buffer rather than to stdout.
If you've got a lot of diagnostic output you want to prevent, than it might be more effective to refactor your code to allow that to be suppressed by an application option.
If you have access to the script replace all echo
with //echo
. Perfect performance increase, but you will need to check multi-line echo statements.
fclose(STDOUT);
This will work cross platform as the first line in the PHP script.