Submitted by Anonymous (not verified) on Fri, 06/19/2009 - 14:41.
It's based on how PHP converts types.
Converting (int) 0 to a string just wraps the number in quotes, so (int)0 becomes (string)"0"
and "0" is not equal to "x"
Converting (string) "x" to an int, the way php does it is by searching the beginning of the string for numerals, it then takes as many of the numerals it finds (until it hits a non-number) and converts that into an integer. If there are no numbers at the beginning of the string, it defaults to (int)0.
It's based on how PHP
It's based on how PHP converts types.
Converting (int) 0 to a string just wraps the number in quotes, so (int)0 becomes (string)"0"
and "0" is not equal to "x"
Converting (string) "x" to an int, the way php does it is by searching the beginning of the string for numerals, it then takes as many of the numerals it finds (until it hits a non-number) and converts that into an integer. If there are no numbers at the beginning of the string, it defaults to (int)0.
therefore, 0 and 0 are equal.