What would be the differnce in php command line app of just echoing or printf etc some string as opposed to getting sdtout stream and writing to it i.e.
$stdout = fopen('php://stdout', 'w');
preguntado el 25 de agosto de 12 a las 20:08
The first thing that comes to mind for me is output buffering.
Considere este guión:
$stdout = fopen('php://stdout', 'w'); ob_start(); echo "echo output\n"; fwrite($stdout, "FWRITTEN\n"); echo "Also echo\n"; $out = ob_get_clean(); echo $out;
FWRITTEN echo output Also echo
which demonstrates that
echo is buffered, and fwrite is not.
La diferencia es que
echo escribe a
php://output which is the output buffer stream.
php://stdout gives you direct access to the processes' output stream which is unbuffered.
Further information regarding streams can be found in the manual: http://www.php.net/manual/en/wrappers.php.php
In addition to the already noted technical difference, there's also the obvious difference in style and convention.
php://stdout is not buffered stream, fwrite can buffer the output using