Reputation: 108
I am trying to multiple & conditions in if statement in Codeigniter. If I use 2 conditions like below:
#<?php if (trim($var1) == '' & trim($var2) == '') : ?>#
Then it works fine. But if I add another & condition like
#<?php if (trim($var1) == '' & trim($var2) == '') & trim($var23) == ''): ?>#
Then it shows error.
How can I solve it?
Upvotes: 0
Views: 4780
Reputation: 26441
Remove this extra bracket,
(trim($var1) == '' && trim($var2) == '') && trim($var23) == ''):
^
Also here you need logical operator &&
and not bit-wise operator &
. Check here to see the difference between them.
difference between & and && in PHP
Upvotes: 2