HasanCseBuet
HasanCseBuet

Reputation: 108

How can I add multiple & conditions in if statement in codeigniter

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

Answers (1)

Rikesh
Rikesh

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

Related Questions