Re: why true?

From: Date: Sun, 11 Aug 2002 15:47:34 +0000
Subject: Re: why true?
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-112036@lists.php.net to get a copy of this message
Because you are comparing a string to a number. PHP has to choose to either compare the two as strings or as numbers. The numerical value of the string 'test' is 0 which means it works out to 0 == 0 which is true. If you want to force a string comparison, you can use strcmp() or, if you want to force a comparison on both value and type, use === instead of == -Rasmus On Sun, 11 Aug 2002, Bas Jobsen wrote: > > echo ('test'==0); > gives 1 why? > > Thanks, > > Bas > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php >

« previous php.general (#112036) next »