Active menu highlighted

If you want to highlight the active menu, it can be done in a relatively simple way, by identifying the page (assigned to the menu) you are on, by using the PHP_SELF variable, from which the file name is extracted. Once the page is identified, the “active” class is applied in the menu, appropriately defined in the CSS file.

So, inside the class attribute, insert the function created above.

Another way to retrieve the name of the current page, you can also use this variant:

The entire code can also be found at this link.

Author: Ovidiu.S

I am quite passionate about this professional area as if I know something - no matter how little - I want to share it with others.

Leave a Reply