Reply to Re: assigned values in 'ByRef' call

Your name:

Reply:


Posted by Darko on 11/06/07 20:02

On Nov 6, 8:27 pm, Csaba Gabor <dans...@gmail.com> wrote:
> In the following PHP code, the final printed line shows 'frob:
> something'. Why is it not 'frob: else'? After all, if I replace the
> first line with $frob = "something"; test ($frob); then the final
> printed line does show 'frob: else'
>
> Csaba Gabor from Vienna
> PHP 5.2.4 on WinXP Pro
>
> test ($frob = "something");
> print "frob: $frob <br>\n";
>
> function test(&$val) {
> print "val pre: $val <br>\n";
> $val = "else";
> print "val post: $val <br>\n"; }

Interesting, indeed. In C++, for an example, it must work as you
expected, and works indeed, since "something" is first assigned to
$frob, then it's passed over to the function, and it does whatever it
wants with it. Here, however, some double assignments seem to have
happened. Is it a bug, or is it some kind of php-specific behaviour,
other users might now.

[Back to original 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

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