PHP Bugs  
php.net | support | documentation | report a bug | advanced search | search howto | statistics | login

go to bug id or search bugs for  

Bug #43283 CLI does not define STDOUT/STDERR with stdin script
Submitted:13 Nov 2007 11:31pm UTC Modified: 21 Nov 2007 11:40am UTC
From:lbayuk at pobox dot com Assigned to:
Status:Closed Category:Documentation problem
Version:5.2.5 OS:Linux
View/Vote Developer Edit Submission

[13 Nov 2007 11:31pm 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 ...

[14 Nov 2007 1:29am UTC] johannes@php.net
I once tried to fix that but it just lead to crazy problems, therefore
making this a documentation issue.
[21 Nov 2007 11:40am 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."

RSS feed | show source 

PHP Copyright © 2001-2009 The PHP Group
All rights reserved.
Last updated: Sat Nov 21 10:30:49 2009 UTC