treehouse : what would you like to learn today?
Web Design Web Development iOS Development

PHP includes...

  • Hi,

    Are there disadvantages to using php includes when building web sites in general?

    I have recently come across the idea and wanted to know if I should be using them on every site that I build and why (or why not). I know they make it easier to maintain etc but is there a reason why I shouldn't be doing it and if there aren't good reasons, why isn't everyone doing it?

    cheers
  • You shouldn't really be using them for content, but things things like including a header, navigation, or footer it is perfectly acceptable.

    (also moved this to the PHP section)
  • and would you say there are any downsides to it as opposed to pure HTML and CSS?

    I suppose you can only do testing on the server.

    Should I be using it for all of my future website projects regardless of size or is it purely personal preference?

    cheers
  • The only dis-advantages I can think of is linking wrong in the included file if it is another folder..

    I do believe it is personal preference.. It's great for headers, footers, and menus..
  • I can't think of any downsides to be honest.
  • OK great,

    in regards to headers though, it can be detrimental to the SEO in regards to the varying description and title tags from page to page right?
  • The meta tags are relatively meaningless. Shouldn't differ from page to page. What'll be really important is the content on those pages. I can't stress that enough.
  • Mr TheDoc is right.

    and yes includes are awesome :)
  • By the way, although includes are great and there are few downsides to them I would suggest using require() because then if the content isn't available the rest of the site won't load. This is good if you don't want your navigation replaced with a load of text generated as an error message.

    Otherwise includes are great!