Jump to content

[SOLVED] Quick Newbie Question about OR


cursed

Recommended Posts

Hey, just a quick question about why this script doesn't work:

 


<?
    $ref = strtoupper($_SERVER['HTTP_REFERER']);
if (strpos($ref,"EXAMPLE1") || (strpos($ref,"EXAMPLE2")) {
        echo "you're from ex";
    } else {
        echo "you're not from ex";
    }
?>

 

On this line,

 

if (strpos($ref,"EXAMPLE1")) {

 

if I remove  || (strpos($ref,"EXAMPLE2"), it works fine. However, when I add that, I get

 

Parse error: syntax error, unexpected '{'

 

 

Thanks in advance for your help.

Link to comment
https://forums.phpfreaks.com/topic/170545-solved-quick-newbie-question-about-or/
Share on other sites

in case you're not sure why that error existed... the parenthesis are color coded to show where they match up with

 

if (strpos($ref,"EXAMPLE1") || (strpos($ref,"EXAMPLE2")) {

 

notice there is no end parenthesis on the red one, which makes it think it's still in the if statement, and does not expect the {

 

rather than add one at the end, i just removed the unnecessary one

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.