note 22620 deleted from language.types.boolean by goba

From: Date: Mon, 04 Nov 2002 12:55:52 +0000
Subject: note 22620 deleted from language.types.boolean by goba
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-38949@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".

« previous php.notes (#38949) next »