array ( 0 => 'index.php', 1 => 'PHP Manual', ), 'head' => array ( 0 => 'UTF-8', 1 => 'en', ), 'this' => array ( 0 => 'features.commandline.io-streams.php', 1 => 'I/O streams', ), 'up' => array ( 0 => 'features.commandline.php', 1 => 'Command line usage', ), 'prev' => array ( 0 => 'features.commandline.usage.php', 1 => 'Usage', ), 'next' => array ( 0 => 'features.commandline.interactive.php', 1 => 'Interactive shell', ), 'alternatives' => array ( ), 'source' => array ( 'lang' => 'en', 'path' => 'features/commandline.xml', ), ); $setup["toc"] = $TOC; $setup["toc_deprecated"] = $TOC_DEPRECATED; $setup["parents"] = $PARENTS; manual_setup($setup); ?>
The CLI SAPI defines a few constants for I/O streams to make programming for the command line a bit easier.
Constant | Description |
---|---|
STDIN |
An already opened stream to <?php stdin , you can
use
<?php |
STDOUT |
An already opened stream to <?php |
STDERR |
An already opened stream to <?php |
Given the above, you don't need to open e.g. a stream for
stderr
yourself but simply use the constant instead of
the stream resource:
php -r 'fwrite(STDERR, "stderr\n");'
Note:
These constants are not available if reading the PHP script from
stdin
.