[TxMt] Re: Unwanted newline php (Allan Odgaard)
ryanfitzer at gmail.com
Sun Dec 13 21:02:04 UTC 2009
> Message: 7
> Date: Sun, 13 Dec 2009 18:30:08 +0100
> From: Allan Odgaard <mailinglist at textmate.org>
> Subject: [TxMt] Re: Unwanted newline php
> To: TextMate users <textmate at lists.macromates.com>
> Message-ID: <30CEA0C1-8185-4A7B-843F-CE02B65D4FA9 at textmate.org>
> Content-Type: text/plain; charset=utf-8; format=flowed
> On 11 Dec 2009, at 8:41, Ryan Fitzer wrote:
>> $fstat = fstat(STDIN);
>> $stdin = fread(STDIN, $fstat['size']);
> I am surprised this works. STDIN is a pipe and can?t be stat?ed for
> file size.
> I would suggest instead using file_get_contents("php://stdin").
One of the reasons decided to use the fstat method as it was the only
documentation I could find on the STDIN subject that I could make
sense of (new to this). This post was my source.:
Also, php.net's explanation offered the following, further making up my mind:
"php://stdin, php://stdout and php://stderr allow direct access to the
corresponding input or output stream of the PHP process. The stream
references a duplicate file descriptor, so if you open php://stdin and
later close it, you close only your copy of the descriptor--the actual
stream referenced by STDIN is unaffected. Note that PHP exhibited
buggy behavior in this regard until PHP 5.2.1. It is recommended that
you simply use the constants STDIN, STDOUT and STDERR instead of
manually opening streams using these wrappers."
I just plugged your recommendation in and it works fine. Thanks for the tip.
Los Angeles, CA
More information about the textmate