Jump to content

PHP Website Structure Question


RaythMistwalker

Recommended Posts

ok atm my php website is mostly run off different php files (index.php profile.php etc)

 

I know that i can also display information based on 1 page by using:

index.php?src=profile

 

then use

$src=$_GET['src'];

if ($src == 'profile') {
Show profile section here
}

 

Are there any advantages or disadvantages to doing it this way as opposed to multiple files?

Link to comment
https://forums.phpfreaks.com/topic/187553-php-website-structure-question/
Share on other sites

One advantage is that dynamic page systems like this can be database driven, allowing you to easily add, remove and edit pages. If the developer of the site creates a decent CRUD system, it means even people without web development knowledge can create new content for the site through a web interface. One slight disadvantage is that to some degree it complicates your code as your having to add a large switch statement to include the relevant pages, but depending on your code structure this is generally a really minor point.

No you still have to create a db connection however if your smart you apply caching and the entire website will be run off on static html pages which get replaced once the user update a page in the back-end.

 

And by update I mean get the new content apply the template and instead of rendering you store it's output to a html file. If your CMS also provides "slugs" like blogs do, you get:

 

about-us.html

Archived

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

×
×
  • 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.