473,399 Members | 4,177 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 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 42546
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: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.