Is anyone aware of a method for an object in PHP5 to discover its own name?
Any help would be great.
Thanks.
coopster
1:08 pm on Apr 3, 2006 (gmt 0)
Welcome to WebmasterWorld, TomAnthony.
I believe get_class() [php.net] will get the results you want.
TomAnthony
1:34 pm on Apr 3, 2006 (gmt 0)
Hi coopster, thanks for the welcome.
get_class() gets me the class name, but I wanted to know the object name.
Is that possible?
I realised I don't need to know this anymore, as I found another way to do what I want, but thought it may be useful for the future.
Thanks!
coopster
1:37 am on Apr 4, 2006 (gmt 0)
Off the top of my head I don't know of a way of the object to discover it's own name. Not that it isn' possible, but if you find that you are going to need to know this you could always create your own var and method to set the name to the instance being established. Perhaps that would work?