php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #66854 STDERR and STDIN are undefined in CLI SAPI
Submitted: 2014-03-08 15:39 UTC Modified: 2014-03-25 14:23 UTC
From: martin dot koranda at gmail dot com Assigned:
Status: Not a bug Package: Built-in web server
PHP Version: Irrelevant OS: windows
Private report: No CVE-ID: None
 [2014-03-08 15:39 UTC] martin dot koranda at gmail dot com
Description:
------------
For some reason, the CLI SAPI doesn't define STDERR and STDIN constants, even though 'php://stderr' and 'php://stdin' still work like you'd expect.

This only affected people without Readline or Libedit.

php 5.5.10 on windows8x64


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2014-03-11 09:57 UTC] ab@php.net
-Status: Open +Status: Feedback
 [2014-03-11 09:57 UTC] ab@php.net
Thank you for this bug report. To properly diagnose the problem, we
need a short but complete example script to be able to reproduce
this bug ourselves. 

A proper reproducing script starts with <?php and ends with ?>,
is max. 10-20 lines long and does not require any external 
resources such as databases, etc. If the script requires a 
database to demonstrate the issue, please make sure it creates 
all necessary tables, stored procedures etc.

Please avoid embedding huge scripts into the report.

php -n -r "var_dump(STDIN, STDERR);"
resource(1) of type (stream)
resource(3) of type (stream)

Please post some reproduce way.

Thanks.
 [2014-03-20 11:14 UTC] martin dot koranda at gmail dot com
-Status: Feedback +Status: Open
 [2014-03-20 11:14 UTC] martin dot koranda at gmail dot com
<?php

echo STDERR;
echo STDIN;

---------------

run this via CLI SAPI like php -S localhost:8080 and the output is:

Notice: Use of undefined constant STDIN - assumed 'STDIN'
Notice: Use of undefined constant STDERR - assumed 'STDERR'

seems that it does not affect those who have Readline/Libedit compiled with php
 [2014-03-25 14:23 UTC] ab@php.net
-Status: Open +Status: Not a bug
 [2014-03-25 14:23 UTC] ab@php.net
Sorry, but your problem does not imply a bug in PHP itself.  For a
list of more appropriate places to ask for help using PHP, please
visit http://www.php.net/support.php as this bug system is not the
appropriate forum for asking support questions.  Due to the volume
of reports we can not explain in detail here why your report is not
a bug.  The support channels will be able to provide an explanation
for you.

Thank you for your interest in PHP.

Ah, it is CLI SAPI in the title but that's about the built-in webserver SAPI. There that's fine. STDIN, STDOUT and STDERR are only defined in the CLI SAPI, there is also special handling for CLI. But starting the built-in server you're not it the CLI SAPI anymore, but in the "Apache like" one. While the pure CLI will reuse the predefined stdin, stdout and stderr FILE pointers, the other CLIs expect some predefined file descriptor.

I don't see how can this be related to libreadline and and others.

thanks
 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Fri Aug 23 02:01:27 2019 UTC