Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:45516 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 22770 invoked from network); 7 Sep 2009 15:50:39 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 7 Sep 2009 15:50:39 -0000 X-Host-Fingerprint: 85.21.236.169 xdmitri.static.corbina.ru Received: from [85.21.236.169] ([85.21.236.169:10749] helo=localhost.localdomain) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id F4/99-04309-DCB25AA4 for ; Mon, 07 Sep 2009 11:50:38 -0400 Message-ID: To: internals@lists.php.net References: <20090904081640.GA28685@joeysmith.com> <753B9AED-C850-4EBA-A828-93A2542F81A2@macvicar.net> <20090904083457.GC28685@joeysmith.com> <698DE66518E7CA45812BD18E807866CE034153BA@us-ex1.zend.net> <4AA24FDB.90409@sci.fi> <4AA25E16.7040803@sci.fi> <30CAA781-B1EE-44E0-AC7B-47FF3DF48FE1@tabini.ca> <698DE66518E7CA45812BD18E807866CE03415400@us-ex1.zend.net> Date: Mon, 7 Sep 2009 19:50:34 +0400 Lines: 69 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.5843 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.5579 X-RFC2646: Format=Flowed; Response X-Posted-By: 85.21.236.169 Subject: Re: [PHP-DEV] shebang skipping in 5.3.0 From: dmda@yandex.ru ("jvlad") From: "Richard Quadling" Newsgroups: php.internals Sent: Monday, September 07, 2009 3:44 PM Subject: Re: [PHP-DEV] shebang skipping in 5.3.0 2009/9/7 jvlad : > And for windows, the shebang line is not used. So becomes part of the > output - no matter what SAPI is used. > > Unless PHP removes/ignores it. > > In fact, I can see no reason at all why PHP should output that line if > it is the first line of the first script being processed. > > I think things get messy when the first script includes completed PHP > scripts which _MAY_ be standalone scripts. > > Say you had task1.php, task2.php, etc. All runnable by themselves. > > Now, say you had tasks.php which simply included task1.php, task2.php, > etc. > > If all have shebangs, then the first one _SHOULD_ be removed, but the > others ... > > Initially yes, but how do you differentiate between a php script > (which may or may not have a .php extension) and a file whose first > line is a shebang - say because it is an example script or a fluke in > the file ... Right, you can have a php script in a file without any extensions at all. Shebang will tell shell what interpreter is to execute. But why would I or anybody else need to differentiate the files by their extensions? The answer is because it's slightly faster. You don't have to read file content to make decision what to do with the file. It's what php's Apache module is doing. Apache configuration file associates .php file extension with appropriate MIME type, then php handler will be called in case if such file is requested. But, with almost the same success you could establish an association between php scripts and php handler by the file content. See magic file distributed with Apache :) and mod_mime_magic docs. I see no reason why #!/blahblahblah should appear in the output 1st line at the leftmost position. Even in the marginal case when you just want to show a sample of a script with shebang, you'd have to add some tags before the line, like below:
#!/blhablahblah...

and finally you can do this with echo:

kinda trivial thing.


I think all shebangs should be removed, regardless they appear in the 
initial script or in the included ones.


-jv