Skip to content
Advertisement

How to add a class to an “a href” element using PHP?

I am trying to add a “nav-active” class to a navigation element with PHP. Here is my code but is not adding the class. What can possibly be wrong?

Here is the bit of code I am trying to change, so my FAQ navigation item has “nav-active” class:

JavaScript

Here is the full nav2.php code:

JavaScript

EDIT: $thisPage is declared in the faq.php file:

JavaScript

Advertisement

Answer

Begining of each php page:

JavaScript

Navar.php:

JavaScript
User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement