What exactly does || mean?

随声附和 提交于 2020-01-04 09:26:09

问题


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 as A or B or A + B
  • xor is meant as A 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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!