Includes using switch statment
PHP Code
+ 0 likes
Please Register to submit score.
| Average Score | 4.0 (of 3 scores) |
| Date Added | May 04, 2007 |
| Last Updated | May 04, 2007 |
| Tags | id include switch |
Introduction
Step 1) Make your layout with all menus and links on it.
Step 2) Place the snippet code in the spot where you want your content to go, probably in the middle of the site.
Step 3) Open up a new fresh php file and add hello world to it. Save the file as news.php.
Step 4) Open a fresh new php file and add this is the about page. Save the file as about.php
Step 5) Change two of your links on the layout page to this.
<a href="index.php?id=news">Home</a>
<a href="index.php?id=about">About</a>
Step 6) Save the 2 files and visit http://yousite/index.php
PS. you can continue to add pages to the snippet below just be sure to add the urls to your layout page.
PHP Snippet:
Includes using switch statment
Posted on May 28, 2007 2:34 pm
Posted on May 28, 2007 2:34 pm
Used in conjunction with header, footer and navigation includes this can be handy.
PHP Snippet:
Includes using switch statment
Posted on May 28, 2007 2:50 pm
Posted on May 28, 2007 2:50 pm
For those, who doesnt know,
| Code: |
| <?php include('inc/head.php'); ?> <? switch($_GET['id']) { default: case "news": include "news.php"; break; case "about": include "about.php"; break; } ?> <?php include('inc/tail.php'); ?> |
PHP Snippet:
Includes using switch statment
Posted on Jul 7, 2007 5:00 am
Posted on Jul 7, 2007 5:00 am
nice and simple. ;)
it took me a while to get into switch, only got into it because my "if" statements were extremely long and messy.
it took me a while to get into switch, only got into it because my "if" statements were extremely long and messy.



