You are here: RE: [PHP] Tidying code for PHP5.0.5/PHP4.4.0 « PHP « IT news, forums, messages
RE: [PHP] Tidying code for PHP5.0.5/PHP4.4.0

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]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация