note 55161 added to types.comparisons

From: Date: Tue, 26 Jul 2005 20:04:32 +0000
Subject: note 55161 added to types.comparisons
Groups: php.notes 
Request: Send a blank email to php-notes+get-92508@lists.php.net to get a copy of this message
In some languages, a boolean is promoted to an integer (with a value of 1 or -1, typically) if used in an expression with an integer. I found that PHP has it both ways: If you add a boolean with a value of true to an integer with a value of 3, the result will be 4 (because the boolean is cast as an integer). On the other hand, if you test a boolean with a value of true for equality with an integer with a value of three, the result will be true (because the integer is cast as a boolean). Surprisingly, at first glance, if you use either < or > as the comparison operator the result is always false (again, because the integer as cast as a boolean, and true is neither greater nor less than true). ---- Manual Page -- http://www.php.net/manual/en/types.comparisons.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+55161 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+55161&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+55161&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+55161&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+55161&report=yes&reason=useless Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+55161&report=yes&reason=non-english Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+55161&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+55161&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#92508) next »