问题
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:)
回答1:
It is the OR logicial operator.
http://www.php.net/manual/en/language.operators.logical.php
回答2:
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 asA or B or A + B
xor
is meant asA or B, not both
References:
- Logical operator
回答3:
This is an OR operator. It is true if any of it's 'parameters' is true.
回答4:
||
means or.
It's a logical or, so it's true if at least one of the terms is true, false otherwise.
来源:https://stackoverflow.com/questions/5666741/what-exactly-does-mean