Page 1 of 1
difference between .inc and .php files
Posted: Thu Mar 25, 2004 1:01 pm
by davidklonski
Hello
I have noticed that many people put their php code in .inc files while others put it in .inc files.
Can someone tell me what are the differences between the two methods and when should I prefer one over the other?
thanks
Posted: Thu Mar 25, 2004 1:23 pm
by markl999
There's no real difference. People just use .inc to indicate that the file is an included one. I prefere just to stick to .php
Also a default server setup is set not to parse .inc files as php files, so if you have a .inc file in your document root it could be possible to view the code in it and reveal sensitive information. You could always use .inc.php and get the best of both worlds.
Posted: Thu Mar 25, 2004 1:27 pm
by Roja
markl999 wrote:There's no real difference.
On the contrary..
markl999 wrote:Also a default server setup is set not to parse .inc files as php files, so if you have a .inc file in your document root it could be possible to view the code in it and reveal sensitive information. You could always use .inc.php and get the best of both worlds.
Thats a serious and signifigant difference - .inc by default is NOT parsed, and so can (usually) be viewed directly.
A novice hearing "there is no difference" might be tempted to put sensitive data there. Bad idea.
Definitely a real difference, and thats how the server handles them - inc is (usually) served plain-text, php is parsed.
Posted: Thu Mar 25, 2004 1:32 pm
by markl999
Yeah, by "There's no real difference." i meant functionally, i should have been clearer. A novice might be tempted, which is why i explained the default setup issue.
But fair point i suppose

Posted: Fri Mar 26, 2004 1:14 pm
by Chambrln
If you use .inc files you should make sure your webserver parses them as .php files.
As stated by the previous posts you don't want your database username and password in your .inc file and then have someone be able to read it plain text.
You can test this by putting a .inc file on your server and calling it directly from the web browser. To be safe you can just use .php as was previously stated.
Posted: Fri Mar 26, 2004 1:16 pm
by andre_c
or put them outside of the webserver, right?
Posted: Tue Apr 20, 2004 8:47 am
by Findus
As said php doesnt by default parse .inc files.
Personaly i think using .inc as in include is wrong. It is a include file yes, but its php aswell. I like to use .inc.php easiest. And in the same way: .class.php.
Posted: Tue Apr 20, 2004 9:09 am
by JayBird
Findus wrote:As said php doesnt by default parse .inc files.
Personaly i think using .inc as in include is wrong. It is a include file yes, but its php aswell. I like to use .inc.php easiest. And in the same way: .class.php.
Agree with that