using 'or' operator not working for menu

Posted by John Wilkes on Stack Overflow See other posts from Stack Overflow or by John Wilkes
Published on 2010-05-03T04:58:11Z Indexed on 2010/05/03 5:08 UTC
Read the original article Hit count: 211

Filed under:

In my code here, I have a CSS class called "active" which I use if the $_GET['page'] == tutorials, php, mysql, etc...

The problem is, even if the 'page' variable is not equal to any of these values, the Tutorials button in this case is still active for some reason.

Any ideas why this would be happening? Am I using the 'or' (||) operand incorrectly?

<?php if($_GET['page'] == 'tutorials' || 'php' || 'mysql' || 'html' || 'css' || 'js') { ?>
      <li class="active"> <?php } else { ?> <li> <?php } ?>

      <a href="index.php?page=tutorials">Tutorials</a>
        <ul>
     <li><a href="index.php?page=php">PHP</a></li>
     <li><a href="index.php?page=mysql">MySQL</a></li>
     <li><a href="index.php?page=html">HTML</a></li>
     <li><a href="index.php?page=css">CSS</a></li>
     <li><a href="index.php?page=js">JS</a></li>
        </ul>
        </li>

© Stack Overflow or respective owner

Related posts about php