Re: Include file questions

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, May 23, 2007 3:48 pm, Stephen wrote:
> 1) Does the filename extension matter? I prefer *.inc? It seems to
> work fine, but I only see others using *.php

>From a strictly "will it work" stand-point, the extension can be
anything you want or none at all.

HOWEVER, there are various security code privacy issues revolving
around the chosen extension.

The point being that you probably don't want your code exposed to the
world, nor executed out of context, most likely.

Some will configure Apache to not serve up .inc files.

Others will add .php on the end, and [try to] make sure that the code
does nothing "bad" if executed out of context.

I personally think one should just move the include files out of the
web tree and use http://php.net/set_include_path (or similar php.ini
settings) to make it impossible for the code to have any chance at all
of being served up as plain text or getting executed out of sequence.

>   2) Does the include file need an opening <?php and ending ?> ?

Yes.

PHP jumps back to HTML "mode" for each include file, because Rasmus
liked it that way back in 1995...  Or he couldn't figure out how to
make it work the other way around...  Or whatever.  It is the way it
is.

And technically, the closing ?> is optional, which some consider a
Feature.  YMMV

-- 
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux