Current course:

Determining the page the user is on

$url = $_SERVER['PHP_SELF'];
$urlParts = explode("/", $url);
$directory = $urlParts[count($urlParts)-2];
$file = $urlParts[count($urlParts)-1];
$pg = substr($file,0,-4);

Ways to use it

After you determine the page the user is on (and set it to $pg variable), you can use it in many ways. One way to use it is to make your menu items appear highlighted based on the current page. Below, we set the class of one of the links to class="at" - then, in our CSS, we set that class to have a brighter font color, or an underline, or a different background image...etc

<a href="index.php" <? if($pg == "home") { echo "class='at'"; } ?>>HOME</a>
<a href="gallery.php" <? if($pg == "gallery") { echo "class='at'"; } ?>>GALLERY</a>
<a href="contact.php" <? if($pg == "contact") { echo "class='at'"; } ?>>CONTACT</a>

Another way, is - based on the page they're on, include different css and/or javascript files:

            switch($pg) {

                  case "index":
                        ?> <link rel="stylesheet" type="text/css" href="css/pg_index.css" /> <script type="text/javascript" src="scripts/pg_index.js"></script> <?

                  case "design":
                        ?><link rel="stylesheet" type="text/css" href="css/pg_design.css" /><?