Why not .inc?
Posted: Mon Aug 19, 2002 10:21 am
In several threads I've seem people advocating not using .inc for include files and only using .php or .inc.php. I don't see why this is good advice. A quick search of the forum didn't turn up a thread on the topic.
Advantages to .inc:
allows a seperation of viewable pages/scripts from class/include files
allows a File directive in the either httpd.conf or .htaccess to forbid direct viewing of the .inc
Cons of a .inc:
loses the context clue of it being a php file
may lead to a sense of false security (forgetting to remove the .inc~ emacs file or similar)
You can address the first con by naming files .php.inc (the opposite of the often suggested advice in the threads). Yes, ideally, your includes should live outside the webtree, in which case it probably doesn't matter what you name them, but we all know sometimes that isn't possible.
Thinking about it a little more, I guess another con is that if you can't set the File Directive you now reveal the include file if its requested and its the web tree. Do people who name their files .inc.php setup a File mask for *.inc.php and restrict viewing of those files, which would seem to use the best parts of both schemes?
Eric
Advantages to .inc:
allows a seperation of viewable pages/scripts from class/include files
allows a File directive in the either httpd.conf or .htaccess to forbid direct viewing of the .inc
Cons of a .inc:
loses the context clue of it being a php file
may lead to a sense of false security (forgetting to remove the .inc~ emacs file or similar)
You can address the first con by naming files .php.inc (the opposite of the often suggested advice in the threads). Yes, ideally, your includes should live outside the webtree, in which case it probably doesn't matter what you name them, but we all know sometimes that isn't possible.
Thinking about it a little more, I guess another con is that if you can't set the File Directive you now reveal the include file if its requested and its the web tree. Do people who name their files .inc.php setup a File mask for *.inc.php and restrict viewing of those files, which would seem to use the best parts of both schemes?
Eric