468,791 Members | 1,796 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,791 developers. It's quick & easy.

Purpose of a ".inc" file?

If a file has a .inc extension, or if it has a .inc.php extension, is it
treated differently by the php interpreter? Or is it just a convention?

I've been calling my included files filename.php and it doesn't seem to
hurt anything. Is it wrong to do that?

E

Jul 17 '05 #1
4 37505
In article <eK********************@typhoon.sonic.net>,
Phester <el**********@thesearentthedroidsyourelookingfor.y ahoo.com>
wrote:
If a file has a .inc extension, or if it has a .inc.php extension, is it
treated differently by the php interpreter? Or is it just a convention?

I've been calling my included files filename.php and it doesn't seem to
hurt anything. Is it wrong to do that?

E


The .php extension is for the webserver. It doesn't matter to PHP (or
the webserver) what the extension of an include file is, but the
extension of the main file must be recognizable as PHP to the webserver.

It's a good idea to give include files also .php as the final extension
for security reasons: if the include file is called directly in a web
browser, the webserver might show the contents of the file as text if it
doesn't recognize its extension. If it has a .php extension the source
code will not be visible.

..inc.php is just a convention.

JP

--
Sorry, <de*****@cauce.org> is een "spam trap".
E-mail adres is <jpk"at"akamail.com>, waarbij "at" = @.
Jul 17 '05 #2
On Sat, 20 Sep 2003 06:39:22 +0000, Phester wrote:
If a file has a .inc extension, or if it has a .inc.php extension, is it
treated differently by the php interpreter? Or is it just a convention?

I've been calling my included files filename.php and it doesn't seem to
hurt anything. Is it wrong to do that?

E

..php (by default) is the normal extension for files.

..inc was (/ still is?) used normally for files being used in include() or
require() calls that reside on a remote server. Including a .php file from
a remote server causes problems as it's retrieved as a parsed file, so you
only retrieve the HTML output, rather than the PHP code you really want.
As .inc isn't normally assigned in the server configuration, this will
normally return as a text/plain file, meaning that all the PHP code is
available when included.

I've never needed to use .inc files personally for remote retrieval, some
seemed to use it in the earlier days for files include()d regardles of
them being local or remote.. personally I prefer .php wherever I can to
prevent accidental viewing of code.

Regards,

Ian

--
Ian.H [Design & Development]
digiServ Network - Web solutions
www.digiserv.net | irc.digiserv.net | forum.digiserv.net
Programming, Web design, development & hosting.

Jul 17 '05 #3
> On Sat, 20 Sep 2003 06:39:22 +0000, Phester wrote:

If a file has a .inc extension, or if it has a .inc.php extension, is it
treated differently by the php interpreter? Or is it just a convention?

....

Jan Pieter Kunst wrote: The .php extension is for the webserver. It doesn't matter to PHP (or
the webserver) what the extension of an include file is, but the
extension of the main file must be recognizable as PHP to the webserver.

It's a good idea to give include files also .php as the final extension
for security reasons: if the include file is called directly in a web
browser, the webserver might show the contents of the file as text if it
doesn't recognize its extension. If it has a .php extension the source
code will not be visible.

.inc.php is just a convention.

JP
....

Ian.H [dS] wrote:
.php (by default) is the normal extension for files. .inc was (/ still is?) used normally for files being used in include() or
require() calls that reside on a remote server. Including a .php file from
a remote server causes problems as it's retrieved as a parsed file, so you
only retrieve the HTML output, rather than the PHP code you really want.

Thanks for the replies. Now it makes sense.

Phester

Jul 17 '05 #4
Ivo
"Phester" <el**********@thesearentthedroidsyourelookingfor.y ahoo.com> wrote:
On Sat, 20 Sep 2003 06:39:22 +0000, Phester wrote:

Jan Pieter Kunst wrote:
> The .php extension is for the webserver. It doesn't matter to PHP (or
> the webserver) what the extension of an include file is, but the
> extension of the main file must be recognizable as PHP to the webserver. >
> It's a good idea to give include files also .php as the final extension
> for security reasons: if the include file is called directly in a web
> browser, the webserver might show the contents of the file as text if it > doesn't recognize its extension. If it has a .php extension the source
> code will not be visible.
>
> .inc.php is just a convention.
>
> JP

Ian.H [dS] wrote:
.php (by default) is the normal extension for files.
.inc was (/ still is?) used normally for files being used in include() or require() calls that reside on a remote server. Including a .php file from a remote server causes problems as it's retrieved as a parsed file, so you only retrieve the HTML output, rather than the PHP code you really want.


Thanks for the replies. Now it makes sense.
Phester

To prevent viewing of inc files, put this in an .htaccess file:
<Files ~ "\.inc$">
Order allow,deny
Deny from all
</Files>

To prevent viewing of the .htaccess file:
<Files ~ "^\.htaccess$">
Order allow,deny
Deny from all
</Files>

Will result in File not Found errors when such file is requested directly,
even though it may well be there!
In Apache 1.3 (I think) FilesMatch is preferred instead of Files.
Ivo
Jul 17 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by yet another michael | last post: by
5 posts views Thread by vishal | last post: by
2 posts views Thread by Steven Burn | last post: by
5 posts views Thread by hntgzr | last post: by
1 post views Thread by CARIGAR | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.