For this example we need meny.php that will hold our meny.

script in meny.php

<div>
    <a href=“index.php”><input type=“button” value=“Home”/></a>
    <a href=“submit.php“><input type=“button” value=“Movie Share”/></a>
</div>

We also need some css.

.button {
    background-image: url(img/button.png);
    background-repeat: repeat-x;
    font-size: 16px;
    padding: 5px;
    border: 1px solid #f1b958;
    color: black;
    font-weight: bold;
}
.button_active {
    background-color: #f6ecca;
    font-size: 16px;
    padding: 5px;
    border: 1px solid #f1b958;
    color: black;    font-weight: bold;
}

How we can add some magic php.

1. We need to get current url and remove .php.

    $url = substr($_SERVER["SCRIPT_NAME"],strrpos($_SERVER["SCRIPT_NAME"],”/”)+1);
    $array = explode(‘.’ , $url);
    $url = $array[0];

2.We need to save this url into variable variable.

    $$url = true;

3.How we will add class changer.

    <a href=“index.php”><input class=“<?php echo !empty ($index) ? ‘button_active‘ : ‘button‘;  ?>”  type=“button” value=“Home”/></a>
    <a href=“submit.php“><input class=“<?php echo !empty ($submit) ? ‘button_active‘ : ‘button‘;  ?>“  type=“button” value=“Movie Share”/></a>

The result in index.php:

To sum up :

The php gets current locatino – index , submit , register … then store it in $$variable. When we are in index the variable will become $index. Then we ask every button if it is $index and if it is we add to it the needed class if it is not we add default class.

Simple as that.