Step1: In Header page Modified navigation link as per your need
<li class=”nav-item <?php if ($phpSelf==”index.php”) { echo “active”; } ?>”><a href=”index.php” class=”nav-link”>Home</a></li>
<li class=”nav-item <?php if ($phpSelf==”about.php”) { echo “active”; } ?>”><a href=”about.php” class=”nav-link”>About</a></li>
<li class=”nav-item <?php if ($phpSelf==”menu.php”) { echo “active”; } ?>”><a href=”menu.php” class=”nav-link”>Menu</a></li>
<li class=”nav-item <?php if ($phpSelf==”blog.php”) { echo “active”; } ?>”><a href=”blog.php” class=”nav-link”>Stories</a></li>
<li class=”nav-item <?php if ($phpSelf==”contact.php”) { echo “active”; } ?>”><a href=”contact.php” class=”nav-link”>Contact</a></li>
<li class=”nav-item cta”><a href=”reservation.php” class=”nav-link”>Book a table</a></li>
Step2: Open particular page like index.php,about.php so on..
Step3: Add these code before including header.php
$phpSelf = trim(basename($_SERVER[‘PHP_SELF’]));
That’s It. Now you can see your navigation link has active class
Thanks. Basant Mallick
Learn how to efficiently set up auto-increment columns in PostgreSQL with this step-by-step guide. From…
Just use below code and modified according to your need. Note: this is very useful…