#43283 [Opn->Csd]: CLI does not define STDOUT/STDERR with stdin script

From: Date: Wed, 21 Nov 2007 11:40:33 +0000
Subject: #43283 [Opn->Csd]: CLI does not define STDOUT/STDERR with stdin script
References: 1  Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-225@lists.php.net to get a copy of this message
ID: 43283 Updated by: vrana@php.net Reported By: lbayuk at pobox dot com -Status: Open +Status: Closed Bug Type: Documentation problem Operating System: Linux PHP Version: 5.2.5 New Comment: This bug has been fixed in the documentation's XML sources. Since the online and downloadable versions of the documentation need some time to get updated, we would like to ask you to be a bit patient. Thank you for the report, and for helping us make our documentation better. "These constants are not available in case of reading PHP script from stdin." Previous Comments: ------------------------------------------------------------------------ [2007-11-14 01:29:09] johannes@php.net I once tried to fix that but it just lead to crazy problems, therefore making this a documentation issue. ------------------------------------------------------------------------ [2007-11-13 23:31:57] lbayuk at pobox dot com Description: ------------ When using the PHP CLI executable, the script can be named on the command line, or fed to PHP through standard input. If using standard input, the file constants STDIN, STDOUT, and STDERR are undefined. I can understand not defining STDIN, since the script is read from there, but why are STDOUT and STDERR not defined? Reproduce code: --------------- <?php fwrite(STDOUT, "Hello, standard output\n"); fwrite(STDERR, "Hello, standard error\n"); Expected result: ---------------- Written to stdout: Hello, standard output Written to stderr: Hello, standard error Actual result: -------------- When run as: $ php nostd.php Works as expected. When run as: $ php < nostd.php This output: PHP Notice: Use of undefined constant STDOUT - assumed 'STDOUT' in ... PHP Warning: fwrite(): supplied argument is not a valid stream resource in... PHP Notice: Use of undefined constant STDERR - assumed 'STDERR' in ... PHP Warning: fwrite(): supplied argument is not a valid stream resource in ... ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=43283&edit=1

« previous php.doc.bugs (#225) next »