Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6

Thread: .inc

  1. #1
    Regular Coder
    Join Date
    Jun 2003
    Location
    Australia
    Posts
    528
    Thanks
    8
    Thanked 8 Times in 8 Posts

    .inc

    Hi..

    Can someone take a moment to explain to me what .inc files are all about. I know they can hold and process php language, but have no idea what their point is... despite the fact that I actually use them.

    I figure I should probably know about the thing I'm using! lol

    Thanks in advance!

    Taylor.

  • #2
    Regular Coder
    Join Date
    Feb 2005
    Location
    West Midlands, UK
    Posts
    623
    Thanks
    0
    Thanked 0 Times in 0 Posts
    As far as I know .inc is just a convenient extension for a file you want to include, you could probably name the file with any extension you want.

    A lot of servers are set up to parse .inc files as php for security purposes, since you can then take measures to stop people snooping at the content of your .inc files. For me I stopped using .inc a while ago, now I just name all my include files with a .php extension, that way I can implement some security in them all without having to rely on the server parsing being set how I want.

    But, to answer the question, yeah I think that's it basically, just a neat way of delimiting your include files so you can tell them apart from your script files I guess

  • #3
    Senior Coder missing-score's Avatar
    Join Date
    Jan 2003
    Location
    UK
    Posts
    2,194
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Yeah, just a way of showing an included file. I've very often seen and sometimes still use .inc.php on the end of my filenames, and I also use .class.php on the end of classes. Depends though, sometimes I just name the files with a standard .php extension.

    Its up to you if you use naming conventions like this, but it's mainly to make your life easier

  • #4
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,987
    Thanks
    4
    Thanked 2,660 Times in 2,629 Posts
    I disagree about making it easier.
    .inc files are not defaulted to be processed within apache. Because of this, if you don't specify for the file to be processed using a .htaccess file, any joe blow can type your filename into their browser and turn up the raw code. Not nessessarly bad, though I've seen all to often people using .inc as an extension for their database configuration options -> which is not cool when someone jacks in.
    If you would like to remember your file is only used for inclusion, I'd recommend assigning it a .inc.php extension. Either that, or move it above your web root to stop anyone from viewing it.

  • #5
    Senior Coder missing-score's Avatar
    Join Date
    Jan 2003
    Location
    UK
    Posts
    2,194
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thats kinda what I meant, personally I have never used a plain .inc file, only .inc.php, but setting up .inc to parsed through .htaccess isn't too difficult and if you find it easier to keep track of .inc files then it would make your life easier. Myself I will stick to .inc.php.

  • #6
    Regular Coder
    Join Date
    Feb 2005
    Location
    West Midlands, UK
    Posts
    623
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I agree with moving the includes outside the web root, regardless of the extension you use, since even if you name the extensions .php they might have unpredictable effects if run independent of the page that is meant to call them - this can be overcome with various checks and calls of course but far easier to just prevent all access to them altogether


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •