phptwitter-bootstrapif-statementstripos

unexpected 'OR' (T_LOGICAL_OR)


I've been trying to make an "active" state in Bootstrap, giving li a class="active" whenever it's on the specified site.

I have this script:

<?php if (stripos($_SERVER['REQUEST_URI'],'/page1.php') !== false) OR (stripos($_SERVER['REQUEST_URI'],'/page2.php') !== false) {echo 'active';} ?>

It's used for a dropdown, that should have the active class whenever it's on either page1 or page2.

I get this error:

Parse error: syntax error, unexpected 'OR' (T_LOGICAL_OR) in your code on line 1

Does anyone know what I've done wrong here? I've tried with "OR" and "||", but none of them work.


Solution

  • The if statement is incorrectly formatted

    <?php if ((stripos($_SERVER['REQUEST_URI'],'/page1.php') !== false) OR (stripos($_SERVER['REQUEST_URI'],'/page2.php') !== false)) {echo 'active';} ?>