note 27792 added to language.types.boolean

From: Date: Wed, 18 Dec 2002 22:23:49 +0000
Subject: note 27792 added to language.types.boolean
Groups: php.notes 
Request: Send a blank email to php-notes+get-41081@lists.php.net to get a copy of this message
Dont really know where else to put this so I'll say it here. After a lot of debugging I have found in my code that '0' (bare, no quotes), appears to match ANY TEXT STRING. So (0 == "R_NOW") is true, (0 == "TRUE") is true, or anything else you might consider throwing at it in a situation where something could be 0 or a string and you just want to check. To avoid this, ALWAYS use preg_match() and NEVER '==' on anything that has the remote possibility of being either a string or an int! -- http://www.php.net/manual/en/language.types.boolean.php http://master.php.net/manage/user-notes.php?action=edit+27792 http://master.php.net/manage/user-notes.php?action=delete+27792 http://master.php.net/manage/user-notes.php?action=reject+27792

« previous php.notes (#41081) next »