Re: PHP class files without <?php at the top

From: Date: Sat, 07 Apr 2012 13:50:05 +0000
Subject: Re: PHP class files without <?php at the top
References: 1 2 3  Groups: php.internals 
Request: Send a blank email to [email protected] to get a copy of this message

On Apr 7, 2012, at 09:39, Tom Boutell wrote:

>> From the viewpoint of someone writing reusable classes, the need to
> start with <?php and reprimand anybody who accidentally puts a newline
> above it is a silly annoyance they don't experience with other tools.
> 
> That said, you are making valid points, I'm not convinced myself that
> "file extensions" necessarily should or could be determined in every
> context. But it seems the most viable way of addressing the issue - if
> a viable way even exists. Partly I want to convince myself that this
> either can or can't ever be improved, and move on either way (:

That "silly annoyance" doesn't seem to bother anyone who writes command line tools,
which require the #! line specifying the command interpreter to be the first bytes in the file, with
no leading white space whatsoever. Especially on unix systems (but also on the Mac), the file
extension does not affirmatively indicate the file type or whether or not it can be executed.

Also, from a CLI perspective, you don't want extensions in the names of your scripts, because
then it causes problems/confusion/extra work if you later decide to change the language the script
is written in.

-John

--
John Bafford
http://bafford.com/



Thread (70 messages)

« previous php.internals (#59404) next »