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.
$abc = (new Example)->someMethod(); $def = &$abc; echo $def;or even$abc = (new Example)->someMethod(); $def = &$abc; unset($abc); echo $def;$abc = array($example->someMethod())?abcActually, it is as shown here just wanted to know if there was an easier way.foobefore. So what exactly are you trying to achieve here? Can you give a use case?