|
Posted by "Michael Sims" on 09/20/05 17:11
Jochem Maas wrote:
>>> foo($a = 5);
>
> by definition the expression is evaluated _before_ the function is
> called - so the expression is not passed to the function, the result
> of the expression is passed ... I was under the impression that the
> the expression evaluates to a 'pointer' (I'm sure thats bad
> terminology) to $a ... which can taken by reference by the function.
>
> possibly I am completely misunderstanding what goes on here.
When used as an expression, an assignment evaluates to whatever is on the right side of the assignment operator, not the left. Example:
var_dump($a = 5);
outputs
int(5)
var_dump($a = "some string");
outputs
string(11) "some string"
So, as far as foo() knows:
foo($a = 5);
and
foo(5);
are exactly the same...
Navigation:
[Reply to this message]
|