Re: [SMARTY] assign_by_ref() and append_b

From: Date: Sat, 03 Aug 2002 13:05:21 +0000
Subject: Re: [SMARTY] assign_by_ref() and append_b
Groups: php.smarty.general 
Request: Send a blank email to php-smarty-general+get-5573@lists.php.net to get a copy of this message
On 3 Aug 2002 at 8:32, Rod Kreisler wrote: > 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. Be careful. Your example will trigger an error when called like $smarty->assign('var', 'direct String'). Have you tested it? Your function definition function assign($name, &$value) { } _does_ require a variable reference to be passed as $value (due to & operator). Furthermore, assign()ing arrays won't be possible. You cannot use default values with references: function assign($name, &$value = null) is not allowed. -- Ferdinand Beyer <fbeyer@clickhand.de> -- Ferdinand Beyer <fbeyer@clickhand.de>

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