What is the result of the following comparison: var_dump(0 == ‘php’);

PHP Intermediate Hard

PHP Intermediate — Hard

What is the result of the following comparison: var_dump(0 == ‘php’);

Key points

  • Loose comparison (==) triggers type juggling.
  • Non-numeric strings cast to 0 when compared to integers.
  • Strict comparison (===) avoids this behavior by checking types.

Ready to go further?

Related questions