Jump to content

Most professional way to create php dynamic website?


shortysbest

Recommended Posts

I'm trying to figure out the best way to code a fully dynamic website. I'm not entirely sure what the best approach to this is. What i have been doing is using subpages so i have one page that i make all my dynamic changes to ie. Navigation bar, header info, then the content area is pulled in with some code from pages such as, content.php. the url for this looks like.

 

www.mysitename.com/index.php?page=content

 

index.php being the template page, and content being content.php.

 

im not sure what the best approach for a professional dynamically built website would be.

Lots of ways to do it, I don't know that any one is the best.  If you want to use query strings, you could do a switch() statement:

 

switch($_GET['page']) {
case 'home':
  include "home.html";
  break;
default:
  include "index.html";
  break;
}

 

Or you could have each .php page contain the same set of includes:

 

<?
include "header.html";
// content here
include "footer.html";
?>

 

or any number of other methods.  You could go so far as to build classes that handle each page element and have a master class that draws the page.  It's really up to you and how you plan to maintain your site's content.

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.