I'm new in the web programming. I made a simple website with a common header. My header is in a folder called inc/common_header.php and i included this header in all my other pages. The header is working good so far, but i want to put different color in the nav menu for the current page. I tried this solution:
<?php
if (strpos($_SERVER['PHP_SELF'], 'about.php')) echo 'class="current"';
?>
This solution is working good but my problem is that i have the navigation bar in a separate page and when i click, the result is always the same inc/common_header.php and not the current page.
Here is my code:
common_header.php
<nav class="navigation-bar fixed-top">
<nav class="navigation-bar-content">
<a class="element brand" href="/"><span class="icon-grid-view"></span> COMPANY NAME</a>
<span class="element-divider"></span>
<a class="element brand" href="/"><span class="icon-home"></span> HOME</a>
<div class="element">
<a class="dropdown-toggle" href="#"><span class="icon-printer"></span> SERVICES</a>
<ul class="dropdown-menu" data-role="dropdown">
<li><a href="#">SERVICE 1</a></li>
<li><a href="#">SERVICE 2</a></li>
<li><a href="#">SERVICE 3</a></li>
<li class="divider"></li>
<li><a href="#">SERVICE 4</a></li>
<li><a href="#">SERVICE 5</a></li>
<li class="divider"></li>
<li><a href="#">SERVICE 6</a></li>
<li><a href="#">SERVICE 7</a></li>
</ul>
</div>
<div class="element">
<a class="dropdown-toggle" href="#"><span class="icon-printer"></span> CALCULATOR</a>
<ul class="dropdown-menu" data-role="dropdown">
<li><a href="calc_home.php">HOME</a></li>
</ul>
</div>
<a class="element brand" href="about.php"><span class="icon-printer"></span> ABOUT</a>
<div class="element place-right">
<a class="dropdown-toggle" href="#"><span class="icon-cog"></span> SETTINGS</a>
<ul class="dropdown-menu place-right" data-role="dropdown">
<li><a href="#">MY ACCOUNT</a></li>
<li><a href="#">MY PRODUCTS</a></li>
<li class="divider"></li>
<li><a href="#">LOG OUT</a></li>
</ul>
</div>
<span class="element-divider place-right"></span>
<button class="element image-button image-left place-right"> USERNAME <img src="img/me.jpg"/></button>
</nav>
Thanks in advance for your help. I will appreciate it.