Can a PHP object instance know its name?

niasagirdcom

New Member
If I have code like this:\[code\]class Person { $age; $height; $more_stuff_about_the_person; function about() { return /* Can I get the person's name? */; }}$John = new Person();$Peter = new Person();print $John->about(); // Print "John".print $Peter->about(); // Print "Peter".\[/code\]Is it possible to print the person's name, stored as the variable name, from the method?As it's not standard procedure, I'm guessing it's a bad idea.I've looked it up and I can't find anything about it.
 
Back
Top