NYCPHP Meetup

NYPHP.org

[nycphp-talk] getting an object's variable name

Andrew Yochum andrew at plexpod.com
Tue Mar 14 13:17:08 EST 2006


On Tue, Mar 14, 2006 at 01:07:01PM -0500, Scott Mattocks wrote:
> Andrew Yochum wrote:
> > On a related note, recently I've been itching for a wat to get the
> > Object ID of an object and possibly way to dereference it.
> > 
> > I mean the one that comes out when you do:
> >     class a { }
> >     $b = new a;
> >     print $b;
> >     # Output:
> >     # Object id #1
> > Yes, output buffering would work but that isn't quite right.
> > debug_zval_dump() has the same issue.
> 
> strval($b) will return the string 'Object id #1'. Not sure if that is 
> exactly what you are looking for but it is a start.

I believe you gett the same result from casting it like:
    $c = (string) $b;
But there is no way to dereference that value though, AFAIK.

Andrew
-- 
Andrew Yochum
Plexpod
andrew at plexpod.com
718-360-0879



More information about the talk mailing list