Re: php compiler

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

 



* Thus wrote Hodicska Gergely:
> Hi!
> 
> > I think the precedence of left and right associative operands can't
> be > compared. The switch between associativities already separates the
> > expression (if it could be explained this way).
> 
> Yes, this behaviour confused me. This is not common in other programming
> languages:
> o  C         : invalid lvalue in assignment
> o  Java      : required: variable
>                found   : value
> o  JavaScript: invalid assignment left-hand side (Mozilla)
>                syntax  error (Internet explorer)
> 
> But for me it isn't egxactly clear how the evaluation order was
> calculated (why doesn't the first = operator executed before &&). Does
> anybody know for example a flowchart, how it is implemented in PHP?

I kind of hinted in my earlier what is going on but:

  $a = 1 && $b = 0;

Is first silently evaluated as:

  $a = (1 && $b = 0);

Now we test the left and right expressions of &&.  The left
expression is true. So the right expression is tested which
happens to be ($b = 0).


Curt
-- 
Quoth the Raven, "Nevermore."

-- 
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