php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #43283 CLI does not define STDOUT/STDERR with stdin script
Submitted: 2007-11-13 23:31 UTC Modified: 2007-11-21 11:40 UTC
From: lbayuk at pobox dot com Assigned:
Status: Closed Package: Documentation problem
PHP Version: 5.2.5 OS: Linux
Private report: No CVE-ID: None
 [2007-11-13 23:31 UTC] 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 ...


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-11-14 01:29 UTC] johannes@php.net
I once tried to fix that but it just lead to crazy problems, therefore making this a documentation issue.
 [2007-11-21 11:40 UTC] 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."
 [2018-06-15 06:42 UTC] robberphex at gmail dot com
This bug still exists!


And I submit pr to fix: https://github.com/php/php-src/pull/3305
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 19 17:01:30 2024 UTC