Here is my navbar.php file
<nav class="navbar navbar-inverse navbar-fixed-top">
<div class="container-fluid">
<div class="navbar-header">
<a class="navbar-brand" href="">Pointless?</a>
</div>
<ul class="nav navbar-nav">
<?php
$active = "";
$pages = array("/index.php","/music/index.php","/pong/index.php");
if ($_SERVER["SCRIPT_NAME"] == $pages[0]) {
$active .= "active";
}
else if ($_SERVER["SCRIPT_NAME"] == $pages[1]) {
$active .= "active";
}
else {
$active = "";
}
echo " <li class=\"$active\"><a href=\"/\">Home</a></li>\n <li class=\"$active\"><a href=\"/music\">Music</a></li>\n <li class=\"$active\"><a href=\"/pong\">Pong</a></li>";
?>
</ul>
</div>
</nav>
Does anybody know why the attribute for ALL nav links is being filled in with "active"? Because I put that addition to the variable in an if statement.
Also, is there anything I should change about the code/is unnecessary?