Doc #43283 [Com]: CLI does not define STDOUT/STDERR with stdin script
| From: | robberphex at gmail dot com | Date: | Fri, 15 Jun 2018 06:42:18 +0000 |
| Subject: | Doc #43283 [Com]: CLI does not define STDOUT/STDERR with stdin script | ||
| References: | 1 | Groups: | php.doc.bugs |
| Request: | Send a blank email to doc-bugs+get-15769@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=43283&edit=1
ID: 43283
Comment by: robberphex at gmail dot com
Reported by: lbayuk at pobox dot com
Summary: CLI does not define STDOUT/STDERR with stdin script
Status: Closed
Type: Documentation Problem
Package: Documentation problem
Operating System: Linux
PHP Version: 5.2.5
Block user comment: N
Private report: N
New Comment:
This bug still exists!
And I submit pr to fix: https://github.com/php/php-src/pull/3305
Previous Comments:
------------------------------------------------------------------------
[2007-11-21 11:40:33] vrana@php.net
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."
------------------------------------------------------------------------
[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 https://bugs.php.net/bug.php?id=43283&edit=1