从另一个PHP页面更改PHP值

I'm trying to add a navbar to all the pages I have, the navbar is a PHP file, and it works for me, but I also wanna put the active navbar button, I tried my best but it didn't work...

This is my navbar.php:

<nav class="navbar navbar-default navbar-fixed-top">
<!--Brand Starts-->

<?php
$active="";
?>

<a class="navbar-brand pull-right animation-sliding-l-r" href="#">
    <img src="images/logo.png" alt="logo"/>
</a>

<!--Brand Ends-->
<button type="button" class="navbar-toggle pull-left collapsed btn navbar-btn btn-block" data-toggle="collapse"
        data-target="#navbar-collapse">
    <i class="fa fa-anchor fa-lg"></i>
</button>

<!--Navbar Buttons Start-->
<div class="collapse navbar-collapse" id="navbar-collapse">
    <ul class="nav navbar-nav">
        <li class="<?php if ($active=='Home') {echo "active";} else {  } ?>"><a href='home.php'><i class='fa fa-home fa-lg'></i> Home</a></li>
        <li class="<?php if ($active=='Store') {echo "active";} else {  } ?>"><a href='store.php'><i class='fa fa-shopping-cart fa-lg'></i> Store</a></li>
        <li class="<?php if ($active=='Report') {echo "active";} else {  } ?>"><a href='report.php'><i class='fa fa-flag fa-lg'></i> Report</a></li>
        <li class="<?php if ($active=='Moderator Application') {echo "active";} else {  } ?>"><a href='moderator-application.php'><i class='fa fa-user-plus fa-lg'></i> Mod Application</a></li>
        <li class="<?php if ($active=='About') {echo "active";} else {  } ?>"><a href='about.php'><i class='fa fa-book fa-lg'></i> About</a></li>
    </ul>
</div>
<!--Navbar Buttons End-->

and I put this in the other pages:

    <?php

    include("includes/navbar.php");
    $active = "Store";

?>

Sorry for the noob question but I searched so far but didn't find anything. Thanks in advance


Hello, i think you have everything good, you just need ton inverse the line ^^

<?php


$active = "Store";
include("includes/navbar.php");

?>

and remove

<?php
$active="";
?>

on the other file

You are not getting appropriate result as you are including the file first and than declaring the variable change your other page code to the below

<?php
$active = "Store";
include("includes/navbar.php");

remove $active=""; from the other file as it override the page value

?>