note 101188 deleted from language.operators.comparison by danbrown

From: Date: Wed, 01 Dec 2010 15:15:27 +0000
Subject: note 101188 deleted from language.operators.comparison by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-174526@lists.php.net to get a copy of this message
Note Submitter: mike dot nicewarner at gmail dot com ---- In response to "mail at markuszeller dot com" on 4 Aug 2010, your logic is flawed. When you put (!$a == 'hello') it evaluates the "!$a" first, then compares that result to 'hello' as an equality. So, if you set $a to 'goodbye', the if becomes: if (!'goodbye' == 'hello') which is false and incorrect. Even if $a were 'hello', it would always return false. It would never execute the code after the if statement. The proper way to code this would be: if (!('goodbye' == 'hello)) which would be true and correct. However, if you do the benchmarks on this syntax, it actually takes significantly longer than the normal ('goodbye' != 'hello') syntax. I did this test repeatedly and confirmed my results are accurate. Please check your code. You are probably getting incorrect results with your syntax.

« previous php.notes (#174526) next »