php-general Digest 3 Jan 2013 15:26:43 -0000 Issue 8085

Topics (messages 320003 through 320003):

Re: Boolean type forced on string assignment inside if statement
        320003 by: Jim Giner

Administrivia:

To subscribe to the digest, e-mail:
        php-general-digest-subscr...@lists.php.net

To unsubscribe from the digest, e-mail:
        php-general-digest-unsubscr...@lists.php.net

To post to the list, e-mail:
        php-gene...@lists.php.net


----------------------------------------------------------------------
--- Begin Message ---
On 1/2/2013 2:02 PM, Marc Guay wrote:
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

You actually use statements like that in order to populate vars? Whatever happened to "simple to understand, easy to maintain" coding practices?

The only time I use a single '=' symbol in an if statement is when I forget to use two of them! Must be my old school, old languages habits but this style of programming reminds me of the days when we used to pack empty spaces in assembler code with constants or byte-size vars in order to save memory back when memory was the most precious resource one had.
--- End Message ---

Reply via email to