note 44086 deleted from types.comparisons by aidan

From: Date: Mon, 24 Jan 2005 14:49:44 +0000
Subject: note 44086 deleted from types.comparisons by aidan
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-83868@lists.php.net to get a copy of this message
Note Submitter: ---- > This means that PHPs implicit typecasting > is *NOT TRANSITIVE* as one might expect > it to be, since "php" == 0, but "php" == true > and 0 == false. Yes, this seems to be non transitive. If you expect transitivity you would expect "php"==0 and false==0 => "php" == false this doesn't happen in PHP. in PHP, "php"==0 and false==0 -but- "php" != false But - it is not legitimate to expect transitivity because you are dealing with different types - you compare strings, booleans and integers. You may expect transitivity when comparing strings to strings, booleans to booleans and ints to ints (this seems to be transitive even in PHP :), but whenever you try to compare strings to ints and booleans to strings you must rely on the translation table PHP provides - which is perfectly logical from a programmers point of view, even if it doesnt provide for that transitivity between a string, a zero integer and a false boolean. This is similar to the problem they teach you in earlier math classes: 5 apples and 4 apples equals to 9 apples, but you can't add 5 apples and 4 bananas.

« previous php.notes (#83868) next »