Re: [PHP] why true?

2002-08-11 Thread Rasmus Lerdorf

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



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




RE: [PHP] why true?

2002-08-11 Thread Maxim Maletsky

Try 

echo ('test'=='0');

and you'll see what Rasmus meant.




Sincerely,

Maxim Maletsky

PHP Beginner
www.phpbeginner.com


 -Original Message-
 From: Bas Jobsen [mailto:[EMAIL PROTECTED]]
 Sent: Sunday, August 11, 2002 4:56 PM
 To: PHP General
 Subject: [PHP] why true?
 
 
 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



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