that article on single page php sites

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
joeldg
Forum Newbie
Posts: 1
Joined: Tue Jun 03, 2003 11:54 am
Location: New Orleans
Contact:

that article on single page php sites

Post by joeldg »

umm..
okay not to be too picky, but why on earth would you use a switch? Every time you want to add a page you would need to code in another "case" stmt.

Why not just dynamically include it after you check if the file exists. (yes, php supports dynamic includes, and I hope they *never* change that)
i.e.

Code: Select all

if($page){
    include $page.".php";
}
This also makes testing easy as you can set up a test page and in the url just add it to see that it works, without screwing up your main page. And it is easy to set up so that it can't be hacked (i.e. remove ../../ and other chars)

I have been setting up sites like this for a long time (i.e. ipn.joihost.com, http://listbid.com/affil/ actually all of listbid.com etc etc.. etc...)

I agree with you that it is the coolest (and fastest) way to program sites (and by the way, googlebot loves them) and like that you are promoting gateway index sites, but using switch, in a larger site like listbid.com where I have 100+ subpages, it is just not workable.

-joedg
pootergeist
Forum Contributor
Posts: 273
Joined: Thu Feb 27, 2003 7:22 am
Location: UK

Post by pootergeist »

ditto to what he said :)
Post Reply