Re: Boolean type forced on string assignment inside if statement
| From: | Marc Guay | Date: | Wed, 02 Jan 2013 19:02:54 +0000 |
| Subject: | Re: Boolean type forced on string assignment inside if statement | ||
| References: | 1 2 3 4 5 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-320001@lists.php.net to get a copy of this message | ||
Something else that's happening with this, which makes it a Bad Idea
(tm) is that when the operator is "or", as it is in my real life
scenerio, the 2nd variable occasionally doesn't get populated if the
first one returns true.
if ($a = "foo" || $b = "bar"){
echo $a."<br />".$b;
}
Returns
foo
And even worse, because I have this in a loop, what can happen is that
if $b gets populated on one loop, it doesn't get reset for the next
one so the data gets seriously bungled.
Moral of the story: Don't be so fancy on your first day back after
vacation. :)
Marc