0
PHP: Why will the code in the if block run?
$a = 2; $b = „Hello world“; if($a && $b) { //the following code will run }
3 odpowiedzi
+ 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 = „“;