Re: [SMARTY-DEV] Re: [SMARTY]Re:[SMARTY-DEV]$smarty.session.object doesn't work in 2.5.0
| From: | Monte Ohrt | Date: | Wed, 16 Apr 2003 13:22:40 +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 11 | Groups: | php.smarty.dev |
| Request: | Send a blank email to php-smarty-dev+get-1192@lists.php.net to get a copy of this message | ||
Yes yes I know how PHP handles references. I misled myself with how
Smarty assigns variables which was later corrected, read the whole
thread first. It's nice to see a post from you though ;-)
Monte
On Wed, 2003-04-16 at 07:36, Andrei Zmievski wrote:
> 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
--
Monte Ohrt <monte@ispi.net>