On Jan 3, 2013, at 11:49 AM, Marc Guay <marc.g...@gmail.com> wrote:

> I just ran this:
> 
> if (($a = "foo") || ($b = "bar")){
>    echo $a."<br />".$b;
> }
> 
> and it only spat out "foo" so I'm guessing things have changed.  :)
> 
> Marc

Marc et al:

I joined late into this conversation, so I may be missing the point, but you 
want to discus strangeness try this:

<?php

if (($a = 'foo') | ($b = 'bar'))                // <-- note the single pipe ( | 
)
        {
        echo "$a <br > $b";
        }
else
        {
        echo 'Neither are populated';
        }
?>

However, the above practice of using one '=' is questionable -- the following 
is better.

<?php

$a = 'foo';
$b = 'bar';

if (($a == 'foo') | ($b == 'bar'))
        {
        echo "$a <br > $b";
        }
else
        {
        echo 'Neither are populated';
        }

?>

Comment out the variables to see how things work. Also change the number of 
pipes to see how things change.

To the more accomplished programmers reading this, here's a question:

What's the difference between using one pipe or two in an 'if' statement?  :-)

Cheers,

tedd

_____________________
t...@sperling.com
http://sperling.com
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to