472,961 Members | 2,471 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,961 software developers and data experts.

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 41907
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: yet another michael | last post by:
hello, bit of a problem which ive played around with for a bit but dont seem to be getting going with:-< Main page is a wrapper to split code and design. It loads a functional page through...
5
by: vishal | last post by:
hello vishal here. i have seen some scripts which includes file like include('time.inc') so can anyone tell me what this file contain. and what is extension
2
by: Steven Burn | last post by:
Just wondering if anyone knows of a way to block the HEAD method from being used outside of the server? (i.e. by a program, or external website). -- Regards Steven Burn Ur I.T. Mate Group...
0
by: rick | last post by:
Hello everyone I am trying to locate the sample files used in "A tour of the code - NavBar" for the redesign of the msdn online website in 1998. They were written and developed by Robert Carter...
4
by: michaaal | last post by:
I have two folders in my website... Folder1 (this is where my #include file is, this is where the style.css is) --Folder2 (Folder2 is inside of Folder1) Folder2 contains a file that has...
5
by: hntgzr | last post by:
I am trying to include a function in a .php file on a different server from the main .php files. I am using: include_path=http://www.anotherserver.com/foldername;...
1
by: summer | last post by:
Hello, I'm not receiving my email, I believe I'm almost there, but can't figure out what I'm missing. Any Clue would be appreciated. Here's my html and asp code. I've included the cdovbs.inc...
18
by: Steven Borrelli | last post by:
Hello, I am using the <?php include() ?statement on my website for organizational purposes. However, one of my includes contains some PHP code. Is there any way for the server to actually...
4
by: CES | last post by:
All, How do you write out a variable in a ASPX .inc?? I've used the following in my code and it worked until I changed the date & MyWebSite, to a server side write... is there any way of getting...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
4
NeoPa
by: NeoPa | last post by:
Hello everyone. I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report). I know it can be done by selecting :...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
0
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
2
by: GKJR | last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.