473,698 Members | 2,426 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 42750
In article <eK************ ********@typhoo n.sonic.net>,
Phester <el**********@t hesearentthedro idsyourelooking for.yahoo.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.ne t | 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**********@t hesearentthedro idsyourelooking for.yahoo.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 ~ "^\.htacces s$">
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
1450
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 ob_start to let me use the headers The class definition
5
9687
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
1667
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 www.it-mate.co.uk
0
1469
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 and George Young and consist of several include files and css files, prepared for ASP. I located the documents in the MSDN Library Archive and this is very, very close to what I would like to do for our own website. The link for the sample downloads...
4
2873
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 this #include statement... <!--#include file="../include.inc"-->
5
2295
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; include(http://www.anotherserver.com/foldername/phpfiletocall.inc); The .inc file is php formatted. Variables are passed to it (not via GET or POST though) and returned using return(variablenames, etc);
1
2999
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 file in the root of my website, I thought that maybe my error. Thank you, Summer
18
2833
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 parse the include? I've tried this before, and it did not parse the include. Rather, it included the file as just plain ASCII. ======================= /*EXAMPLE 1*/ /*index.php*/
4
1977
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 this to work within an inc file structure? Thanks in advance. - CES <% Response.WriteFile("Yourfile.FileExtension"); %> ----- Yourfile.FileExtension ------ <div id="copyright">
0
8609
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9030
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8899
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8871
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7737
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6525
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5861
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
3052
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2007
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.