note 40818 added to control-structures
| From: | Steve at SJHanna dot com | Date: | Mon, 15 Mar 2004 22:15:12 +0000 |
| Subject: | note 40818 added to control-structures | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-66883@lists.php.net to get a copy of this message | ||
A bit of advice about using == in if statements: Instead of
if ($a == 0 ) ...
write
if (0 == $a) ...
Clearly, the order doesn't matter. However, if you inadventently were to write
if ($a = 0) // Note the assignment!
your test would always return false! That's because you've assigned the value 0 to $a,
then tested that value, and 0 is false. On the other hand, if you wrote
if (0 = $a) ...
the processor will give you an error, since you can't assign a value to a constant.
----
Manual Page -- http://www.php.net/manual/en/control-structures.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+40818
Delete -- http://master.php.net/manage/user-notes.php?action=delete+40818&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+40818&report=yes
Search -- http://master.php.net/manage/user-notes.php