[Phpwm] Site Structure

Tom Jemmett tom.jemmett at gmail.com
Fri Dec 9 12:59:43 GMT 2005


> I'd have thought you're probably better off with something along the lines of :
>
> if(isset($_GET['page'])) {
>        $desired_page = $_GET['page'];
>        $allowable = array("index", "aboutme", "foo", "bar", "something", "else");
>        foreach($allowable as $ok) {
>                if($ok == $desired_page) {
>                        include($ok);
>                        continue;
>                }
>        }
> }

Another way of doing this would be a switch statement:

switch ($_GET['page']) {
  case "pictures":
    include ("pictures.php");
    break;
  case "news":
    include ("news.php");
    break;
  default:
    include ("welcome.php");
}

I think this looks better and is easier to understand when you look
back at your code.



More information about the Phpwm mailing list