I want to echo the name of the variable object i’m calling, in this case controller_01.
I’m using get_class, but it wont print the variable name, only the object type 🙁
<?php
class remoteControl{
private $chip = "Intel64<br />";
public function openCase(){
echo "The controler has a " .get_class($this);
return $this->chip;
}
}
$control_01 = new remoteControl();
echo $control_01-> openCase();
?>
You can’t do that just like that. An object can have multiple references, but the object isn’t itself aware of those references.
The only thing you could do, is to enumerate through every variable you can find and check if it points to the object. But those references could exists also in arrays, or in properties of other objects.
And your design is really flawed if you need the object to find its reference variables this way.