0

So, I have a snippet of php code which turns the link on a navigation bar green if the variable is right. However, no matter what all links on the bar are green

echo "
<li "; 
if ($page = 'slither');{echo"style='background-color:#4CAF50;'";};
echo " class='link'><a href='?page=slither'>Slither</a></li>
<li ";
if($page = 'agar');{echo"style='background-color:#4CAF50;'";};
echo " class='link'><a href='?page=agar'>Agar</a></li>
<li ";
if ($page = 'home');{echo"style='background-color:#4CAF50;'";};
echo " class='link'><a href='?page=home'>Home</a></li>
  • 1
    You're not doing comparisons correctly. `($page == 'slither')`, not `($page = 'slither')`. – cteski Jan 30 '17 at 18:46

1 Answers1

0

You are using = which assign value. You have to compare using == :)