0

PHP: Why will the code in the if block run?

$a = 2; $b = „Hello world“; if($a && $b) { //the following code will run }

7/12/2019 5:49:39 PM

Niklas

3 Answers

New Answer

+1

Because everything diffrent from zero will be interpreted as true! Or any non Empty Objects or Strings/Arrays... I know this from C where it is the same.

+1

This may have to do with the bitwise representation of a empty string.

0

empty strings will also be interpreted as true $c = „“;