At 02:36 6/2/2001, Andrei Zmievski wrote:
>At 02:31 AM 2/6/01 +0200, Zeev Suraski wrote:
>>In my opinion - if people want to run such files as CGI's, they should be
>>using .cgi extension and +x them, and not run them through the php.exe
>>CGI as .php files. At any rate, we need to decide which of the two
>>behaviors is correct, because right now, both are possible (Netscape
>>Server appears to be one of the only servers that display the rare case,
>>in which this line is not swallowed and displayed as regular text).
>>
>>Other opinions..?
>
>Until 4.0.4pl1, I've never had a problem with running scripts that had
>#!/usr/local/bin/php as the first line. I could do:
>
> php -q foo.php
>
>or:
>
> ./foo.php (after chmod +x)
>
>And it worked - and still works on Linux. Solaris is a different matter,
>though...
As I said, in most cases it will swallow that line, even when (IMHO) it's
not supposed to, like in the former case you describe (the way it is
essentially means that you can't have a file that begins with #, no biggy,
but still weird). In one exception (when it can't figure out the filepath
from the environment and reverts to argv0), it doesn't check for this #
line, and thus, will spit it out as regular output if it's there (look at
cgi_main.c, around line 720).
Generally, I think the right solution would be making only
./foo.php (after chmod +x)
work. php -q foo.php shouldn't treat foo.php as if it was a shell script.
This solution has two major drawbacks:
- It might break people's setups.
- It's not very easy (and perhaps not possible) to detect in which mode we
are. We determine whether we're in CGI or not by looking at the
environment variables, but those will be around even if we're running as an
#! executable, as long as we're running as a CGI...
Unless someone has a bright idea as to how to deal with it, I think the
best thing to do would be fixing the inconsistent case to be consistent
with the other cases, even if this whole behavior is a bit wrong...
Zeev
--
Zeev Suraski <[EMAIL PROTECTED]>
CTO & co-founder, Zend Technologies Ltd. http://www.zend.com/
--
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]