Effervescent

This is just my temporary blog till I create my own on my site, one that actually counts statistics (posts, profile views, etc) correctly.

Name:
Location: Colombo, Sri Lanka

There's way too much to type.

2005-07-11

Navigation menu in PHP

this is the basic concept of how i handle navigation in PHP.
it's not commented but it's very basic but if there is something you want to ask, just ask on this blog :)




<?php
$prefix = '/path/to/file/myPrefix.';
$postfix = '.inc.php';
$defaultPage = 'home';
$errorPage = '404';

$incFile = $prefix . $_GET['page'] . $postfix;
$default = $prefix . $defaultPage . $postfix;
$error = $prefix . $errorPage . $postfix;
if(file_exists($incFile))
{
switch($_GET['page'])
{
case 'home':
case 'about':
case 'contact':
include_once $incFile;
break;

case '':
@include_once $default;
break;

default:
@include_once $error;
break;
}
}
else
{
echo '<h1>Page Not Found: 404</h1>';
}
?>