note 89916 modified in language.types.type-juggling by danbrown

From: Date: Sat, 28 Mar 2009 19:41:37 +0000
Subject: note 89916 modified in language.types.type-juggling by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-152557@lists.php.net to get a copy of this message
Here is something that was a not obvious bug in my code. Comparison statements cast string to int automatically if one of the other variable is an int. <?php $a=3; $b='3d'; if ($a==$b) { echo "a is b"; } else { echo "a is not b"; } ?> Result: a is b This can cause some issues if you don't expect it --was-- Here is something that was a not obvious bug in my code. Comparison statements cast string to int automatically if one of the other variable is an int. $a=3; $b='3d'; if ($a==$b) { echo "a is b"; } else { echo "a is not b"; } Result: a is b This can cause some issues if you don't expect it http://php.net/manual/en/language.types.type-juggling.php

« previous php.notes (#152557) next »