#! scripts as PHP scripts

From: Date: Tue, 06 Feb 2001 00:31:50 +0000
Subject: #! scripts as PHP scripts
Groups: php.dev 
Request: Send a blank email to php-dev+get-45822@lists.php.net to get a copy of this message
The current CGI implementation supports a different way of running PHP scripts as if they were executables, using #!/usr/local/bin/php style header. The current implementation also inconsistently handles files of that format that are executed as regular PHP scripts (i.e., under the Apache module, or even when running through the PHP CGI under a Web server). In most circumstances, the CGI implementation will 'swallow' the first line if it begins with #. That's despite the fact that inside the context of a CGI (cgi=1), this line is pretty much meaningless, and worse, it's quite legitimate to have a file begin with #... In one case only (if the startup code couldn't determine which file to open, and reverts to argv0), then it will actually treat this line properly and display it as regular output. 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..? Zeev -- Zeev Suraski <zeev@zend.com> CTO & co-founder, Zend Technologies Ltd. http://www.zend.com/

« previous php.dev (#45822) next »