... there are ways to do it (set an ‘active’ class based on page url) in PHP too. For anyone not using a framework that adds a class, here's a simple way to do it in PHP...
At the very top of the web page - above all HTML, even doctype;
<?php
$pg = basename(substr($_SERVER['PHP_SELF'],0,strrpos($_SERVER['PHP_SELF'],'.'))); // get file name from url and strip extension
?>
This will take a value of "about-us" from an URL that looks like www.mywebsite.com/about-us.php".
And to use it in a menu's li elements to add a class...;
<li class="<?php if($pg=='about-us'){?>active<?php }?>;">;
<a href="/about-us.php">About Us</a>
</li>
The output on the "about-us.php" page when it is viewed in browser will look like this;
<li class="active">
<a href="/about-us.php">About Us</a>
</li>
Taken from here