note 40486 deleted from language.control-structures by aidan

From: Date: Thu, 07 Oct 2004 13:51:12 +0000
Subject: note 40486 deleted from language.control-structures by aidan
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-78128@lists.php.net to get a copy of this message
Note Submitter: freshprincecharming at yahoo dot com ---- Remember that PHP is type free. That means that if you do a comparison with the == operator on 'this string' and the integer value 0, they WILL MATCH! For example: if ('some string' == 0) // THIS WILL MATCH! To avoid this situation, make sure you use the === operator, or cast your variables where needed, like so: if (string($key) == 'some string') //do something; I just spent 20 hours debugging my code because my variable $key was 0 and it evaluated the expression ($key == 'some string') as true! Hope this helps someone.

« previous php.notes (#78128) next »