This question already has an answer here:
- Get variable name of object inside the object php 3 answers
I would like to know, if it is possible in PHP (using reflection or not) to get the variable name abc
inside the class method in this example.
class Example
{
public function someMethod()
{
// once this method is called, I want it to echo `abc` in this example
}
}
Now, when I call the method using a variable name like
$abc= (new Example)->someMethod();
echo $abc; // abc
I would like to see the name of the variable, 'foo' shown, in other words the class would have to be aware of the variable name, when returning the methods contents.