RE: Re[2]: Sv: Re: [SMARTY] assign_by_ref() and append_by_ref()

From: Date: Sat, 03 Aug 2002 12:32:51 +0000
Subject: RE: Re[2]: Sv: Re: [SMARTY] assign_by_ref() and append_by_ref()
References: 1  Groups: php.smarty.general 
Request: Send a blank email to php-smarty-general+get-5572@lists.php.net to get a copy of this message
To do this you don't need function overloading or allow_call_time_pass_reference. function assign($name,&$value,$use_ref=false) { if ($use_ref) { // need to keep reference $this->_tpl_vars[$name] = &$value; } else { // need to dereference $this->_tpl_vars[$name] = $value; } } This would be backward compatible AND allow passing of any variable (not just objects) as a reference. > -----Original Message----- > From: Hendy Irawan [mailto:ceefour@gauldong.net] > Sent: Saturday, August 03, 2002 1:41 AM > To: smarty-general@lists.php.net > Subject: Re[2]: Sv: Re: [SMARTY] assign_by_ref() and append_by_ref() > > > smarty-general, > > > Why not add a third parameter to assign() that tells assign() to either > > copy or pass by reference. You could default this new > parameter to copy > > for backwards compatability. I'm new to PHP and Smarty, so don't laugh > > too hard if I'm way off base. > In the current PHP architecture, is there a way this can be done? > > Your idea is excellent, though I think it'd be difficult to implement > in PHP since one function would have to accept two different types of > arguments. (is there any such thing as "function overloading" in PHP?) > > I personally like the assign_by_ref() way of doing things, but if > anyone knows about PHP's overloading capabilities, PLEASE DO TELL > ME!!!!!! > >

« previous php.smarty.general (#5572) next »