php website in one file?

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
User avatar
dhrosti
Forum Commoner
Posts: 90
Joined: Wed Jan 10, 2007 5:01 am
Location: Leeds, UK

php website in one file?

Post by dhrosti »

I'v got a small site to build and i was just wondering if there are any advantages to building it all within one file, using a big switch statement or something to display the different content. It might make it a bit simpler to share common variables, session checks, etc. Anyone have any thoughts on this?
User avatar
CoderGoblin
DevNet Resident
Posts: 1425
Joined: Tue Mar 16, 2004 10:03 am
Location: Aachen, Germany

Post by CoderGoblin »

Maintenance would be a nightmare 8O
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

That's what include() is for. ;)
User avatar
superdezign
DevNet Master
Posts: 4135
Joined: Sat Jan 20, 2007 11:06 pm

Post by superdezign »

Break everything up into separate files, and put

Code: Select all

if(preg_match('/pagename'/, $_SERVER['PHP_SELF'])) header("Location: index.php");
at the top of every file to stop people from straying.

And to determine which page you're on, $_GET variables would handle it well.
Post Reply