You are here: Re: Missing STDOUT, STDERR with CLI « PHP Programming Language « IT news, forums, messages
Re: Missing STDOUT, STDERR with CLI

Posted by ljb on 11/13/07 23:19

jstucklex@attglobal.net wrote:
> ljb wrote:
>> Using the PHP CLI executable, if the script to run is fed to PHP via
>> standard input, then it seems PHP does not define any of the standard
>> stream constants STDIN, STDOUT, and STDERR. While I can understand not
>> defining STDIN, since that's where the script is, I think not defining
>> STDOUT and STDERR is a bug. Any comments before I open a bug report?
>> Confirmation?
>>
>> --- Test script 'nostd.php' ---
>> <?php
>> fwrite(STDOUT, "Hello, standard output\n");
>> fwrite(STDERR, "Hello, standard error\n");
>> -------------------------------
>> Run: $ php nostd.php
>> Works as expected.
>> Run: $ php < nostd.php
>> Produces NOTICE and Warning messages about STDOUT and STDERR not defined.
>>
>
> I've never tried it, but I can see why it could work that way.
>
> When you do "php nostd.php", stdin is fed into the script, and stdout
> and stderr would be, also. But, as you noticed, when you try to use
> "php < nostd.php", stdin is redirected. So PHP probably doesn't open
> stdout or stderr to the script, either.
>
> You can try to submit it as a bug, but I'll give you good odds it will
> be classified as "working as designed".

Maybe I'll take that bet. I looked at the PHP source (php_cli.c function
cli_register_file_handles()), and it seems to me that it is written such
that if any of the 3 streams cannot be opened, then none are opened. I
can't see why this is necessary, but you could be right - it might be "as
designed".

I would have opened the bug already, but they just release 5.2.5 and once
they put out a new release they don't take bug reports for the 'ancient'
releases like 5.2.4.

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация