[php-maint] Bug#636146: Bug#636146: php5-cli: STDIN not defined in CLI

Robert Kawecki thewanderer at gim11.pl
Mon Aug 1 13:20:32 UTC 2011

> The PHP documentation doesn't say anything about assignment to variables. Are you sure this is a valid use case?
> Ondřej Surý

Yes, it's a valid use case, and this is reproducible with any reference
to these constants, not only an assignment.
During testing today, I've found that this only happens when the script
is piped to PHP or typed in manually. When running `php -f ./file.php`
or similar way (that is, when the input file is not "-"), STDIN, STDOUT
and STDERR are defined.
This fact is not mentioned anywhere in the documentation, but it appears
to be an explicit design decision, as the PHP source contains an "if",
preventing the constants from being defined when reading the script from
a file. See:
line 1101

I only found out about that after posting the bug report.
So either the online documentation is incomplete regarding the CLI SAPI
and these constants, or the conditional statement is in the source by

More information about the pkg-php-maint mailing list