RE: Tidying code for PHP5.0.5/PHP4.4.0

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

 



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

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