0

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?

Cœur
  • 37,241
  • 25
  • 195
  • 267
HasanCseBuet
  • 108
  • 3
  • 13

1 Answers1

2

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

Community
  • 1
  • 1
Rikesh
  • 26,156
  • 14
  • 79
  • 87