Jump to content

Seperate files or one index + includes?


Maelstrom

Recommended Posts

I am sure this has been asked before, but i couldnt find any mention of it anywhere.

What is the better option, having seperate files for each single page in your site that include() the header and footer information, like most sites do, or have one single index page - with the layout information in that - that includes pages depending on a $_GET variable? As far as I can see, there are pros and cons for each method. The first is easier, and has tidier URLs, while the second is easier to make large site wide global changes to. Which is better, and if there is no definate answer, which type is better in different situations?

Thanks.
Link to comment
Share on other sites

welcome to the forums! i hope you find lots of great helps and advice here.

this is one of those areas that is really a situational answer, like you referred to. if you have [b]more[/b] pages that need individuality than uniformity on your site, you're definitely better off to make the separate pages, however, if your site requires uniformity across the scope, you most likely are better off combining as much of the code as you can. each case is different. you've also got to take into account how much SEO you are trying to do. many engines out there still do not fully follow PHP paths, so you're better off with a full directory structure that can easily be followed by spiders and robots. it all depends on the type of site and what kind of content you're displaying. there really isn't an easy answer to this question ;)
Link to comment
Share on other sites

Just to think about:

I used to use a single loader (index.php) and then call the page based on the URL (index.php?page=page.php).  But what had happened is that I started needing additional variables passed to the page and using includes you couldnt pass variabes thru the URL.

For example:

if I had:
index.php?page=page.php

And then later on in the page, I had:
include ('page.php');

That would be fine, but I couldnt do this:
include ('page.php?somethervar=foo');

This cuased major problems for me, and just recently decided to switch to having multuiple files with and include of the header and footer.  I dont like (or rather didnt like) this style, but I have soared past my problems and am now much more productive.  I agree that it is cleaner and seems more secure to use a single loader page, but I am making apps as opposed to simple web pages, and I constantly need to throw variables around.

Hope this helps.

I also agree with obsidian's post, it is totally a preference thing to do as well as based opn what you are trying to do (at one point I was happily using frames  ;) - it was a simple app on a private network where security wasnt an issue).

Take care....
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.