You are here: Re: Equivalent of upvar « PHP Programming Language « IT news, forums, messages
Re: Equivalent of upvar

Posted by Oli Filth on 09/16/05 15:19

am_ggh@hotmail.com said the following on 15/09/2005 17:48:
> Erwin
>
> Thanks for replying. I appreciate your input.
>
> Yes you are right, I have the need to set a value to the variable in
> the calling environment (my case happens to be a function within a
> function), In fact I need to possibly initialize variables (since they
> might not even exist) in the calling function. $GLOBALS etc. lead to
> unwanted side effects because of the nature of the task at hand*.
>

Would passing a variable by reference do what you want?

e.g.

function foo()
{
$a = 5;
bar($a);
// now $a == 8
}

function bar(&$var)
{
// $var is a reference to $a in the callee...
$var = 8;
}

--
Oli

 

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

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