Advanced PHP
Q99 / 100

What is the behavior of PHP's loose comparison with "0" and false?

Correct! Well done.

Incorrect.

The correct answer is B) "0" == false is true because PHP converts "0" to 0 then to false; but "0" is truthy in boolean context

B

Correct Answer

"0" == false is true because PHP converts "0" to 0 then to false; but "0" is truthy in boolean context

Explanation

PHP type juggling: "0" is falsy (empty-string-like in bool context), so "0" == false is true. But (bool)"0" === false. This asymmetry is a known PHP gotcha, fixed with ===.

Progress
99/100