This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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