Re: Question about "if" statement evaluating (0=="string") as TRUE

From: Date: Fri, 13 Dec 2002 19:34:29 +0000
Subject: Re: Question about "if" statement evaluating (0=="string") as TRUE
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-128203@lists.php.net to get a copy of this message
I think this is happening because you're comparing apples to oranges. Your first comparison causes an integer to be compared to a string. Because the string "string" evaluates to the integer value 0, the comparison succeeds. The manual recommends the use of the identical comparison operator (===) instead, or--better yet--the strcmp() function when comparing two strings. Cheers, Marco -- ------------ php|architect - The magazine for PHP Professionals The monthly worldwide magazine dedicated to PHP programmers Come visit us at http://www.phparch.com!

« previous php.general (#128203) next »