[nycphp-talk] getting an object's variable name
Andrew Yochum
andrew at plexpod.com
Tue Mar 14 12:57:34 EST 2006
On Tue, Mar 14, 2006 at 11:30:33AM -0600, Jeff Knight wrote:
> Greetings from TX you chilly state-tax-paying nerds! I hear the
> group's alcohol consumption has diminished dramatically since I left.
> I bet T.G.I.F misses me the most.
>
> I actually have a question for y'all (all'y'all? y'all all?). Is it
> possible to get the variable name used by an object from that object?
> If I had
>
> class Example {
> function varName() {
> // what goes here?
> }
> }
>
> $nyphp = new Example() ; $txphp = new Example();
>
> I want $nyphp->varName() to return the string 'nyphp', and
> $txphp->varName() to return 'txphp'
Not that I'm aware of. You'd need access into the symbol tables.
Sounds like a nice extension.
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.
Ideas?
Thanks,
Andrew
--
Andrew Yochum
Plexpod
andrew at plexpod.com
718-360-0879
More information about the talk
mailing list