Re: [SMARTY-DEV] Re: [SMARTY]Re:[SMARTY-DEV]$smarty.session.object doesn't work in 2.5.0

From: Date: Wed, 16 Apr 2003 12:36:17 +0000
Subject: Re: [SMARTY-DEV] Re: [SMARTY]Re:[SMARTY-DEV]$smarty.session.object doesn't work in 2.5.0
References: 1 2 3 4 5 6 7 8 9 10  Groups: php.smarty.dev 
Request: Send a blank email to php-smarty-dev+get-1190@lists.php.net to get a copy of this message
On Tue, 15 Apr 2003, Monte Ohrt wrote: > ugh :-) > > IIRC,We're talking about assigning variables in Smarty via the assign() > class method call. If you look at the assign() method, you will see that > arrays are broke apart with a foreach() loop, thus forcing a copy, not a > reference. Umm, how are they _broken_ exactly? Foreach will happily operate on whatever you pass it. The only time the value will be copy-separated is if you write to it. > $bar = 'blah'; > $foo = $bar; <-- REFERENCE > $smarty->assign('foo', $bar); <-- REFERENCE > > $bar = array('blah','blah2'); > $foo = $bar; <-- REFERENCE > $smarty->assign('foo', $bar); <-- COPY No, these are exactly the same. Part of the confusion comes with the terminology. A "reference" is a value (zval internally) with is_ref field set to 1. This means that all the variables that have this value will change all together if the value is changed. If is_ref is 1, but refcount > 1 (meaning, more than one variable uses this value), then it is not a reference. -Andrei http://www.gravitonic.com/ The 3 great virtues of a programmer: Laziness, Impatience, and Hubris. --Larry Wall

« previous php.smarty.dev (#1190) next »