Views:
Author: Chris
Alright, say you have a template and you want to include pages just in the middle of your site without having to copy and past the template on every page, well switch can help you!
<?php
switch($_GET[page]) { //$_GET[page] is the url, eg site.com/?page=xxx you can change [page] to anything and it will change the URL's
default: //default page to include
include('main.php');
//other files - remember to link your files to site.com?page=whatever (or use modrewrite to make them site.com/page)
break;
case "tutorials":
include('tutorials.php');
break;
case "contact":
include('contact.php');
//add more of these as needed, it is usually safer to add something to the name of the file to include so people don't guess the url and try to hack it, such as contact.php could be contact.inc.php, then again I just told you inc so don't try that now, do something different
break;
case "VAR": //VAR is at the end of the url, so if somebody types in ...?=VAR it will include the file mentioned below
include('whatyouwant.php'); //sometimes you might need a slash at the start or a $_SERVER[DOCUMENT_ROOT]."whatyouwant.php"
break;
} //End switch
?>
Hope that helps!
1