A simple example might be (unoptimised for clarity):



  // Get the file from the url - assuming PHP > v4.1.x 
  $file = $_GET("file");

  // Remove case sensitivity
  $file = strtolower($file);

  // To stop people including just ANY old file, we are going to use a
  // to validate the page they are after. All include files have been
  // with .page in order to stop /etc/passwd being outputed (for
  switch ($file) {
    case "main" : case "home" : case "elephant" : case "..." : {
      include "pages/".$file.".page";
    default : {
      // "unknown.page" could be an error message giving out a 404.
      include "unknown.page";


Switch is one way of doing it, you could also do it through array's
(using in_array) if you wish all to have the same action. Switch's allow
you to specify different actions for different pages (when you move onto
session validated pages you'll find that ability invaluble) ... Also
comes in useful when your variable parsing script is in the same php
file as your display script. [Id give examples but Im too tired to be
bothered heh]

- Dan

PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to