> Because "8" != 8. "8" (and "08") is a string with the numerals
representing
> the number eight. It is not the number eight. (think back to basic math,
the
> difference between a number and a numeral)

Actually, "08" is equal to 8 in PHP. PHP will convert the string to an
integer and the two will compare as equal.

> PHP does some conversions for you automatically but that just saves you
from
> yourself. (Personally, I wish it wouldn't. People have more trouble
> *because* of the automatic conversions than they would if they had to do
the
> converting themselves.)

Someone already posted why the problem was happening, because the numbers
were being converted to invalid octal numbers and being set to zero.

Run this bit of code for an example:

   echo "<br>" . ((01 == 1) ? "Match" : "No Match");
   echo "<br>" . ((02 == 2) ? "Match" : "No Match");
   echo "<br>" . ((03 == 3) ? "Match" : "No Match");
   echo "<br>" . ((04 == 4) ? "Match" : "No Match");
   echo "<br>" . ((05 == 5) ? "Match" : "No Match");
   echo "<br>" . ((06 == 6) ? "Match" : "No Match");
   echo "<br>" . ((07 == 7) ? "Match" : "No Match");
   echo "<br>" . ((08 == 8) ? "Match" : "No Match");
   echo "<br>" . ((09 == 9) ? "Match" : "No Match");

The last two won't match because 08 and 09 are invalid octal numbers, like
Kirk Johnson already said.

So "08" != 08 and 8 != 08, for example.

---John Holmes...


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to