Re: Get reference count on a variable.
| From: | Curt Zirzow | Date: | Sat, 21 Aug 2004 14:24:26 +0000 |
| Subject: | Re: Get reference count on a variable. | ||
| References: | 1 2 3 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-194393@lists.php.net to get a copy of this message | ||
* Thus wrote Robert Cummings:
> On Sat, 2004-08-21 at 00:10, Curt Zirzow wrote:
> > * Thus wrote Robert Cummings:
> > > Hi All,
> > >
> > > I think I'm looking for something that doesn't exist, but just in
> > > case thought I'd check the list. Does anyone know if a PHP function
> > > exists to get the number of references on a given variable's data? I was
> > > hoping to create a way for a factory to automatically recycle resources
> > > without the need for the developer to call some kind of free() method.
> > > If I could get the internal reference count then I'd be able to
> > > determine if it is free by virtue of only 1 reference (the factory).
> > > This is for PHP4 btw, the solution is trivial in PHP5 using destructors.
> >
> > unfortantly there isn't a method to determain this.
> >
> > Be careful with PHP5, i'm not sure if its applicable in your
> > situation, but there does seem to be rumor that php5 objects are
> > assigned by reference, which isn't true:
> >
> > $o1 = new object();
> > $o2 = $o1;
> > unset($o2);
> >
> > the Object still exists, and the destructor isn't called.
> >
> > vs.
> >
> > $o3 = new object();
> > $o4 =& $o3;
> > unset($o3);
Sorry, those unset's should be:
$o2 = null;
and
$o3 = null;
It's was to demonstrate that = and =& are *not* the same thing as
one would believe since the term 'assigned by reference' is used.
Curt
--
First, let me assure you that this is not one of those shady pyramid schemes
you've been hearing about. No, sir. Our model is the trapezoid!