Skip to content

Instantly share code, notes, and snippets.

@gfarrell
Created June 11, 2014 16:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gfarrell/6e884aad402ed44925ba to your computer and use it in GitHub Desktop.
Save gfarrell/6e884aad402ed44925ba to your computer and use it in GitHub Desktop.
<?php
// First we get the variable we want to look at from the $_GET array
$page = $_GET['p'];
// We should never trust the user's input to be safe
// So let's restrict the possibilities with a switch() statement
// If the input is invalid, we return some sort of error
switch($page) {
case 'home':
// show the home page text
break;
case 'about':
// show the about page text
break;
case 'contact':
// show the contact page text
break;
default:
// none of the above
// show an error
die('Invalid page!');
break;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment