From: "Richard Quadling" <rquadl...@googlemail.com>
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 <d...@yandex.ru>:

> 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:
<body><pre>#!/blhablahblah...

and finally you can do this with echo:
<?php
  echo "#!/blahblahblah";
?>
kinda trivial thing.


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


-jv



-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to