NYCPHP Meetup

NYPHP.org

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

Scott Mattocks scott at crisscott.com
Tue Mar 14 13:07:01 EST 2006


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.

-- 
Scott Mattocks
http://www.crisscott.com



More information about the talk mailing list