Re: Boolean type forced on string assignment inside if statement

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux