RaythMistwalker Posted January 7, 2010 Share Posted January 7, 2010 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? Quote Link to comment https://forums.phpfreaks.com/topic/187553-php-website-structure-question/ Share on other sites More sharing options...
cags Posted January 7, 2010 Share Posted January 7, 2010 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. Quote Link to comment https://forums.phpfreaks.com/topic/187553-php-website-structure-question/#findComment-990239 Share on other sites More sharing options...
RaythMistwalker Posted January 7, 2010 Author Share Posted January 7, 2010 so it has the advantage that I don't have to open a mysql connection every time i load a page since i have it opening when the page opens? Quote Link to comment https://forums.phpfreaks.com/topic/187553-php-website-structure-question/#findComment-990244 Share on other sites More sharing options...
ignace Posted January 7, 2010 Share Posted January 7, 2010 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 Quote Link to comment https://forums.phpfreaks.com/topic/187553-php-website-structure-question/#findComment-990250 Share on other sites More sharing options...
teamatomic Posted January 7, 2010 Share Posted January 7, 2010 Why switchs? $src=$_GET['page']; if (!file_exists("$path_content/$page.php") { $src='index'; } include("$path_content/$src.php"); Quote Link to comment https://forums.phpfreaks.com/topic/187553-php-website-structure-question/#findComment-990267 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.