Using .inc files for headers and footers

Discussion in 'HTML & Website Design' started by NickBe, Mar 15, 2008.

  1. #1
    I use .inc files for my headers and footers. I do not know why I use it though. The first site I ever built was build by looking at the code from a site my old business partner built. SO I took a look at this code and started piecing things together. He had .inc headers so I have been using them for about 1 year now but I am not sure what the benefits are (if any). I guess from a design stand point it makes everything cleaner but besides that what are the advantages and disadvantages?
     
    NickBe, Mar 15, 2008 IP
  2. AfterHim.com

    AfterHim.com Peon

    Messages:
    1,923
    Likes Received:
    51
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Just use PHP and use the include function.
     
    AfterHim.com, Mar 15, 2008 IP
  3. NickBe

    NickBe Peon

    Messages:
    12
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    that's what I do?

    I am asking what are the benefits of using .inc files as opposed to just throwing all the header info into the main file.
     
    NickBe, Mar 15, 2008 IP
  4. RelevantBuZZ_PR

    RelevantBuZZ_PR Guest

    Messages:
    101
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Think of .inc files as common files of common codes. Let's say you have multiple web pages. Rather than coding each file/page with common codes you link them to a file. That way you can update one file and it will change all pages that have the .inc in them.

    Common practice is to use .inc for Headers, Footers, Meta, Head, navigation and any other common codes you can think of that will be redundant in all pages. It's very efficient way of coding.
     
    RelevantBuZZ_PR, Mar 16, 2008 IP
  5. blueparukia

    blueparukia Well-Known Member

    Messages:
    1,564
    Likes Received:
    71
    Best Answers:
    7
    Trophy Points:
    160
    #5
    .inc doesn't really do anything. You can save your files as .html,.php,/inc.html, or .blueparukiaisawesome.

    Shall make no difference.
     
    blueparukia, Mar 16, 2008 IP
  6. RelevantBuZZ_PR

    RelevantBuZZ_PR Guest

    Messages:
    101
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Actually, I strongly disagree. It can have it's benefits (as I suggested above) when used correctly. :)
     
    RelevantBuZZ_PR, Mar 16, 2008 IP
  7. blueparukia

    blueparukia Well-Known Member

    Messages:
    1,564
    Likes Received:
    71
    Best Answers:
    7
    Trophy Points:
    160
    #7
    But you can do that with any file extensions.

    You can use include('file.extension"), and i will work.

    I'd normally save them as .html or .php so anyone can access them.
     
    blueparukia, Mar 16, 2008 IP
  8. deques

    deques Peon

    Messages:
    206
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    0
    #8
    inc means includes.
    it doesnt matter what you name them to, but its better to have a well organized structure to know what file serves what.

    use .inc as file extension, you can also use .txt as file extension, but you wouldnt know wheter they are includes or not. better use a name that relates to that purpose
     
    deques, Mar 16, 2008 IP
  9. Erthy

    Erthy Peon

    Messages:
    254
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    0
    #9
    Plus, browsers can cache the file, and when it loads again, it will load faster.
     
    Erthy, Mar 16, 2008 IP
  10. deques

    deques Peon

    Messages:
    206
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    0
    #10
    uhm, no. browsers dont cache the inc files. it caches processed files, which mostly are .html files.
     
    deques, Mar 16, 2008 IP
  11. hans

    hans Well-Known Member

    Messages:
    2,923
    Likes Received:
    126
    Best Answers:
    1
    Trophy Points:
    173
    #11
    I use same since nearly 2 yrs

    disadvantages are none in my experience

    advantages are manifold

    1. you can modify header section with some seasonal promotion without having to change pages
    2. you can add banner to your site or other sites
    3. you can insert your adsense code - thus having a very few files to control your adsense formats and appearances for the entire site ( that is definitely a HUGE advantage )
    4. for footer - you can modify site-wide links to new sections or major pages

    overall it makes the site dynamic while using flat files that are far easier to maintain. it allows you to change in a single file some text that appears on a wide range of pages across the site

    but

    to fully benefit from include files - use a system by subfolders or topics that allows you to individually adapt the different major topics of your site.

    I have typically 3 include files

    top ( above the fold = ATF ) for adsense, for "advertise on this site, and for the social bookmarking widget and seasonal additional banners for my OWN site's promotion.

    top-LEFT - for a vertical adsense 160x600 and my own vertical banners or addtional info

    footer - for links and G search box

    I would NEVER want to miss this feature again - it has brought me TEN thousands of additional adsense $ / year since I implemented the fully tested and refined include system in my flat files some 1,5 yrs ago
     
    hans, Mar 16, 2008 IP
  12. RelevantBuZZ_PR

    RelevantBuZZ_PR Guest

    Messages:
    101
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #12
    For a flat-file system using the .inc is perfect.
     
    RelevantBuZZ_PR, Mar 16, 2008 IP
  13. webrehash

    webrehash Peon

    Messages:
    163
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    0
    #13
    Correct me if I'm wrong, but the main purpose of the .inc extension as opposed to a .php or .html extension is so a browser won't render the file when loaded. I could be way off base here, but I thought I read that somewhere...
     
    webrehash, Mar 20, 2008 IP
  14. kk5st

    kk5st Prominent Member

    Messages:
    3,497
    Likes Received:
    376
    Best Answers:
    29
    Trophy Points:
    335
    #14
    For most html includes, it wouldn't matter if someone saw them or not. Unless otherwise directed, the server will send .inc files as text/plain. The problem arises when your php logic includes a file containing things like user names and passwords, or sql queries; all of which are security issues. For those files, you should put them in a directory outside the document root tree. It is also a good idea to add this directive to the httpd.conf file or your .htaccess file.
    
    <Files ~ "\.inc$">
        Order allow,deny
        Deny from all
    </Files>
    Code (markup):
    Anyone trying to GET an .inc file will see a 404 error.

    cheers,

    gary
     
    kk5st, Mar 20, 2008 IP