BPD
BPD

Reputation: 81

What exactly does || mean?

return (empty($neededRole) || strcasecmp($role, 'admin') == 0 || strcasecmp($role, $neededRole) == 0);

What exactly does the || mean in this statement? Can someone put this in english for me.

I promise I've googled this but I guess I don't know what to google for because I can't find anything.

thanks:)

Upvotes: 3

Views: 21945

Answers (4)

boisvert
boisvert

Reputation: 3729

|| means or. It's a logical or, so it's true if at least one of the terms is true, false otherwise.

Upvotes: 1

Dr McKay
Dr McKay

Reputation: 2568

This is an OR operator. It is true if any of it's 'parameters' is true.

Upvotes: 1

Shoe
Shoe

Reputation: 76240

Googling symbols is always hard. Don't worry: || means or in the statement. Don't confuse it for Xor which is slightly different:

  • or or || is meant as A or B or A + B
  • xor is meant as A or B, not both

References:

Upvotes: 3

Daniel A. White
Daniel A. White

Reputation: 190943

It is the OR logicial operator.

http://www.php.net/manual/en/language.operators.logical.php

Upvotes: 4

Related Questions