View Full Version : PHP Includes links help


MCG321
04-03-2005, 05:52 PM
My latest problem:
I'm having trouble with my header include. It has links (Home, Forum, etc), but depending on what page it's on, I think I need it to change.

For example, when the header is on a page in my main directory, I just need one of the links to link to "index.php". But when it's in a subfolder, it needs to link to "../index.php". Is there a way to make it "know" where to link to or automatically changed based on the directory that it's in?

Fenring
04-03-2005, 07:07 PM
<?php
switch ($page) {
case "":
case "index":
include "header.php";
include "main.php";
include "footer.php";
break;
default:
include "header.php";
include $page.".php";
include "footer.php";
break;
}
?>

Use that as your index.php file and you won't have this problem. Conceivably, it's possible but I don't know the method.