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

From: Date: Wed, 14 Nov 2007 01:29:10 +0000
Subject: #43283 [Opn]: CLI does not define STDOUT/STDERR with stdin script
References: 1  Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-209@lists.php.net to get a copy of this message
ID: 43283 Updated by: johannes@php.net Reported By: lbayuk at pobox dot com Status: Open -Bug Type: CGI related +Bug Type: Documentation problem Operating System: Linux PHP Version: 5.2.5 New Comment: I once tried to fix that but it just lead to crazy problems, therefore making this a documentation issue. Previous Comments: ------------------------------------------------------------------------ [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 (#209) next »