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

From: Date: Tue, 15 Apr 2003 20:44:29 +0000
Subject: Re: [SMARTY-DEV] Re: [SMARTY]Re:[SMARTY-DEV]$smarty.session.objectdoesn'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-1172@lists.php.net to get a copy of this message
> 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. > > So, examples of Smarty & PHP (4.x): > > $bar = 'blah'; > $foo = $bar; <-- REFERENCE > $smarty->assign('foo', $bar); <-- REFERENCE > > $bar = array('blah','blah2'); > $foo = $bar; <-- REFERENCE > $smarty->assign('foo', $bar); <-- COPY nope, the second one is a reference, too it gets a copy if you do $smarty->assign(array('foo' => $foo, 'bar' => $bar)); because only THEN a foreach is executed look carefully at method assign() again: If you assign an ARRAY to smarty, it is a reference If you assign variables VIA AN ARRAY (like in my example above), they get copied Best regards, I hope you're not angry with me or something :) David > > Monte > > On Tue, 2003-04-15 at 15:03, Wom.bat wrote: > > > The value is not referenced if: > > > > > > 1) the value being assigned is an array > > > 2) the value being assigned is an object > > > > > > Otherwise you are correct, only a reference counter is incremented. > > > > No Monte, sorry, but you are wrong. Please read > > http://www.zend.com/zend/art/ref-count.php again, there > > you'll find this at > > multiple points in the document, for exampe at "Reference Counting in PHP4": > > "Reference counting is used for all the PHP 4 basic data types: such as > > integers, booleans, strings, arrays, objects and resources" > > Below that statement, you'll find more proof on that. > > > > Regards, > > David > -- > Monte Ohrt <monte@ispi.net> > > > -- > Smarty Development Mailing List (http://smarty.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > >

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