[nycphp-talk] comparison with zero
Craig Thomas
craig at juxtadigital.com
Fri Jul 21 07:14:44 EDT 2006
Michael Southwell wrote:
> All strings are evaluated as zero unless they begin with a character
> which can be interpreted as a numeral. You can test this as follows:
>
> echo intval( 'a string');
>
> see
> http://us3.php.net/manual/en/language.types.string.php#language.types.string.conversion
> for more information
>>if('one' == 0){
>> echo 'one is equal to zero';
>>}
>>you will get 'one is equal to zero'. This may be a stupid question, but
>>why if you compare a string to zero, does it evaluate to true?
Try:
if('one' === 0){
echo 'one is equal to zero?';
}
http://www.php.net/manual/en/language.operators.comparison.php
More information about the talk
mailing list