<html>
<head>
<title>My Page</title>
</head>
<body>
<?
// no variable value... your main page
if (!$page) {
include("home.php");
}
// if the variable is "info"
elseif ($page == "info") {
include("info.php");
}
// if the variable is "stats"
elseif ($page == "stats") {
include("stats.php");
}
// if all else fails, could be your "404 error" page
else {
include("error.php");
}
?>
</body>
</html>
<?
if (!$page) {
include("pages/home.php");
}
elseif ($page == "info") {
include("pages/info.php");
}
elseif ($page == "stats") {
include("pages/stats.php");
}
else {
include("pages/error.php");
}
?>
Originally posted by Canuckkev
Isn't it a lot easier to just:
PHP:<?php include("./$page.php"); ?>
switch($page)
{
case '':
include('blah.html');
break;
case 'stats':
include('stats.html');
break;
case 'so on':
include('whateverotherpage.html');
break;
}
You can also read a dir, and loop the files in the dir and print them with some kind of order....Originally posted by AlieXai
Good idea, bad programming none the less. Later on, you use to learn switch() instead of if() { } elseif() { } else { }...
Code:switch($page) { case '': include('blah.html'); break; case 'stats': include('stats.html'); break; case 'so on': include('whateverotherpage.html'); break; }
Originally posted by AlieXai
Good idea, bad programming none the less. Later on, you use to learn switch() instead of if() { } elseif() { } else { }...
Code:switch($page) { case '': include('blah.html'); break; case 'stats': include('stats.html'); break; case 'so on': include('whateverotherpage.html'); break; }