What Exactly Does || Mean?

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:)

3

4 Answers

It is the OR logicial operator.

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:

0

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Elena Rostova
Author

Elena Rostova

Elena Rostova holds a Master's degree in Public Health Journalism. She covers groundbreaking medical research, holistic wellness trends, mental health awareness, and nutritional science.