Daily Technology News, Tips, and Reviews | Subscribe to Jason Slater Technology BlogTechnology Feed | Join Jason Slater on TwitterTwitter | Thursday 2nd September 2010

PHP: Page Inclusion using GET selection

By Jason Slater
  • DiggThis
  • Share

Sample code to handle page inclusion based on get values 

// parse the passed value
switch($_GET['page'])
{
  // check for page1
  case('page1'):
  include 'page1.php';
  break;
  // check for page2
  case('page2'):
  include 'page2.php';
  break;
  // send other enquiries to our 404 page
  default:
  include 'page404.php';
  break;
}

Related

Leave a comment!

Add your comment below, or trackback from your own site. You can also subscribe to these comments via RSS.

Be nice. Keep it clean. Stay on topic. No spam.

You can use these tags:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

This is a Gravatar-enabled weblog. To get your own globally-recognized-avatar, please register at Gravatar.