0

I know that '0' == 0 is true in PHP, but this:

<?php
    if ('a' == 0)
        echo "YES";
?>

will print YES on the screen.
This bothers me. The question:

Why the string 'a' (or "a") is equal to the number 0?
I was thinking about automatic char->number conversion, but 'b' == 1 is false...

PHP Versions tested:

  • 5.4.4-14+deb7u14
  • 5.3.29
tonjo
  • 1,394
  • 1
  • 14
  • 27

0 Answers0