Reputation: 101483
I'd like to do this:
$var = ($var2 . $var3)
This means $var
is only true if $var1
and $var2
are truthy (anything that will cast to a boolean true
).
Upvotes: 0
Views: 1409
Reputation: 46692
Do it like this:
$var = ($var2 && $var3);
or simply like SQL:
$var = ($var2 and $var3);
Read more about Logical Operators and how to use them at PHP manual. Both &&
and and
operators are good enough for it, the only difference being the precedence.
Upvotes: 2
Reputation: 655239
.
is the string concatenation operator. Use &&
for a boolean AND operation:
$var = $var2 && $var3;
Upvotes: 1