For such a small nav bar then JeremyC's solution will be fine I'd say, just means hardcoding the file-key "about" in each of your ten files.
PHP Code:
<?php
$this_page = "about";
include 'nav_bar.php' ;
?>
If you wanted to do it another way you could detect the filename from your $_SERVER array.
(just do var_dump($_SERVER); on one of your pages to see what else is available to you).
Then you could keep your pages in an array and generate your nav bar from that:
nav_bar.php
PHP Code:
<?php
// you just maintain this array, which you keep handy at the top of the file
$pages = array(
'/index.php' => 'Home',
'/about.php' => 'About',
'/contact.php' => 'Contact us',
// etc
);
// grab the var
$this_page = $_SERVER['SCRIPT_NAME'];
#TODO you could test if $this_page exists in the permitted array first
echo '<ul>' ; // start menu
foreach( $pages as $key=>$val ) { // loop thru array
echo '<li><a href="' . $key . '"'; // start nav link
if( $key == $this_page) echo ' class="active"'; // if array key '/index.php' matches $this_page
echo '>' . $val . '</a></li>' . PHP_EOL ; // end nav link
} // end of loop
echo '</ul>' ; // end menu
Sorry, I am unable to test this on my setup today, but that should give you another idea about how you could tackle this problem -- but as I say, JeremyCs idea is just fine.
Bookmarks