note 65226 modified in language.operators.bitwise by bjori

From: Date: Thu, 27 Apr 2006 09:24:29 +0000
Subject: note 65226 modified in language.operators.bitwise by bjori
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-109838@lists.php.net to get a copy of this message
[Editors note: This is not true. You will have to check every possible combination, for instance: $a = array(); $b = ""; $c = null; $d = 0; will print "not equal" but if you set $b = null and $c = "" it will print "equal"] For the sake of completeness I want to note that a check for equality doesn't have so long winded as in the (wrong) example below. Because of simple laws of logic you don't have to check every possible combination of the variables. The following code will be no surprise for most of you, but for some people it could be helpful. -Tim <?php $a = 42 ; $b = 42 ; $c = 1138 ; $d = 1701 ; echo $a==$b && $b==$c && $c==$d ? "equal" : "not equal" ; // echoes not equal $a = 42 ; $b = 42 ; $c = 42 ; $d = 42 ; echo $a==$b && $b==$c && $c==$d ? "equal" : "not equal" ; // echoes equal ?> --was-- For the sake of completeness I want to note that a check for equality doesn't have so long winded as in the (wrong) example below. Because of simple laws of logic you don't have to check every possible combination of the variables. The following code will be no surprise for most of you, but for some people it could be helpful. -Tim <?php $a = 42 ; $b = 42 ; $c = 1138 ; $d = 1701 ; echo $a==$b && $b==$c && $c==$d ? "equal" : "not equal" ; // echoes not equal $a = 42 ; $b = 42 ; $c = 42 ; $d = 42 ; echo $a==$b && $b==$c && $c==$d ? "equal" : "not equal" ; // echoes equal ?> http://php.net/manual/en/language.operators.bitwise.php

« previous php.notes (#109838) next »