It should be written as ...
dd($user === "Admin" || $user === "Superuser");
... instead. There are two separate conditions that should be checked separately.
As about the current situation, it's... funny. See,
truthy value, or the second operand without changing their types).
But it's PHP, and here the result of
|| operation is always a
boolean value - either
false. It's no surprise that it's
true in this case, as only two string values in PHP are considered
falsy - an empty string and
'0'. The first operand of
'Admin' || 'Superuser' is neither, so this expression evaluates to
So it becomes...
dd($user == true);
Again, with proper comparison operator -
=== - you should've noticed the difference here. But it's
==, so it converts its operands' types before actually comparing them.
By the rules of type coercing (which are described quite nicely in the docpage), when one value of the comparison is
boolean, the other always gets converted to
boolean too. As
$user isn't either
'0', it gets converted to
So it finally becomes this:
dd(true === true);
Guess what's the result? )