PHP Tutorial : Dynamic pages Switch and Case
Jan 2, 2009 Useful PHP
Do you want to keep all the content in only one single page to avoid searching and editing and opening tons of files for only one modification?
For that, we can do a single php dynamic page which will act as multiple pages. The form will be “page.php?pagename=home” or “page.php?pagename=contact”. We need the “switch and case” features from php. Here is the usage :
<?php $page = $_GET['pagename']; switch($page) { case "home": print "We are in the homepage now"; break; case "contact": print "Here is our contact page"; break; } ?>
Add more dynamic php pages by doing a case like : case “products”: print “our products”; break;
Good luck!
Tags: dynamic, dynamic pages, multiple pages in a single one, pages, php dynamic, php dynamic pages, php pages


May 14th, 2009 at 6:30 pm
thanks for the advice. I knew I was forgetting something
August 19th, 2009 at 4:55 pm
thank’s for your info.
readers from Indonesia
November 17th, 2009 at 4:28 am
I have used this same method before reading this post …