note 22620 added to language.types.boolean

From: Date: Tue, 25 Jun 2002 14:41:18 +0000
Subject: note 22620 added to language.types.boolean
Groups: php.notes 
Request: Send a blank email to php-notes+get-32174@lists.php.net to get a copy of this message
if (1 == (int) true) echo "this is true"; if (((boolean) -100 == true) && ((boolean) 1 ==true)) echo "yes, this is true"; if (1 == ((int)((boolean) -100))) echo "Uhh... and this is also true. Does 1=100?"; Casting from boolean to integer we get 0 or 1, casting from any integer other than 0 to boolean, we get "true". There is no right answer for question "is 1=true or not": so long you gentelmen keep comparing dogs to cats, you may get odd and different results. Right answer is, "thanks to automatic type juggling in php any number other than 0 or 0.0 and any string other than "" is equal to true". -- http://www.php.net/manual/en/language.types.boolean.php http://master.php.net/manage/user-notes.php?action=edit+22620 http://master.php.net/manage/user-notes.php?action=delete+22620 http://master.php.net/manage/user-notes.php?action=reject+22620

« previous php.notes (#32174) next »