note 33787 added to language.operators.comparison
| From: | matthew dot somerville at trinity dot oxford dot ac dot uk | Date: | Mon, 07 Jul 2003 23:45:00 +0000 |
| Subject: | note 33787 added to language.operators.comparison | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-51652@lists.php.net to get a copy of this message | ||
dragon_rage4's code has a mistake: "if ($myVar == $myVar++)" will always evaluate to
true, so the second case will also print "They are equal".
And to avoid the "assignment in an if statement pit", one could reverse the comparison -
putting "if (5 == $myVar)" is fine, but "if (5 = $myVar)" will throw up an
error.
----
Manual Page -- http://www.php.net/manual/en/language.operators.comparison.php
Edit Note -- http://master.php.net/manage/user-notes.php?action=edit+33787
Delete Note -- http://master.php.net/manage/user-notes.php?action=delete+33787&report=yes
Reject Note -- http://master.php.net/manage/user-notes.php?action=reject+33787&report=yes