RE: [PHP] Odd Code Error.

From: Date: Wed, 21 Jan 2004 11:35:18 +0000
Subject: RE: [PHP] Odd Code Error.
Groups: php.general 
Request: Send a blank email to php-general+get-175282@lists.php.net to get a copy of this message
[snip] > Interesting. I wouldn't have expected that. However, that is how it > should work. Check out table K-2 on this page: > > http://us4.php.net/manual/en/types.comparisons.php > > '==' is a loose comparison. You can use '===' instead which will give > you the results you are looking for. > > if ($EA === "NFH") > Hmm after all this time, are you saying its best to use === instead of == in any application ? [/snip] For strings, yes. And you should also re-order the question ... if("NFH" === $EA) Why, you ask? Because this will prevent possible assignment errors. If you accidentally type if($EA = "NFH") NFH gets assigned to $EA and is true...you might not see the error until quite a bit later. However if you accidentally type if("NFH" = $EA) an error will get thrown right away.

« previous php.general (#175282) next »