1

I have written a Joomla extension that counts traffic and I recently ran into a strange issue. I normally use

if (empty($items) AND ($bot == 0) AND ($iplock == 0)) 

and it worked fine until recently one of the uses sent me a message explaining that the system didn’t count unless he changed it to this.

$ei = empty($items) AND ($bot == 0) AND ($iplock == 0);

if ($ei == 1)

He is using PHP version 5.3.19 on his web server, can anyone explain why the second would work but the first wouldn't.

Thanks

1
  • The problem must lie somewhere else. Commented Mar 9, 2013 at 15:09

1 Answer 1

4

The two statements are not equal

Second statement is evaluated like this

($ei = empty($items)) AND ($bot == 0) AND ($iplock == 0);

because $items are empty, $ei get value 1.

Do not use AND operator, it has lower precedence than =, use &&

Check operator precedence

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks what you said make sense.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.