Jump to content

Archived

This topic is now archived and is closed to further replies.

Maelstrom

Seperate files or one index + includes?

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.

Share this post


Link to post
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 ;)

Share this post


Link to post
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....

Share this post


Link to post
Share on other sites

×

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.