On Thursday 03 January 2013 11:33:22 Marc Guay wrote:
> > First, did the original poster realize that he was assigning a value
> > to the variable $a in the 'if' statement?
> Hello,
> Yes, I did, and if you read my responses you can see that I came to
> the realisations you describe.  I don't think that anyone suggested
> there was a bug.
> > $a is true (ie it is not set to a 'false' value,
> > whatever PHP uses for false) and $b is "bar" because that is what it
> > is set to.  Since the evaluation is within a bracket, the interior
> > values ($a, $b) are set BEFORE the if condition is evaluated.
> Regarding this I'm a bit confused.  In the case of an OR operator, $b
> is not "bar" because it follows the "true" path as you said earlier.
> Probably just a glitch in the English language.  I'll file a bug for
> that.
> Marc

Hi Marc:

I'm not at all sure of that.

There are two things happening in parallel here: first the interior of the 
brackets is evaluated as necessary, in this case the $a is set to "foo" and 
the $b is set to "bar".  Then the exterior part of the statement is 
evaluated:  if ($a..... ).  It is this last operation that results in the 
path selection through the code, and in this case $a is "true", $b is not 
evaluated.  ....mind you I'm basing this on my university basic programming 
course from almost 50 years ago :-)  



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

Reply via email to