PHP:对象的回显变量名称?

| 我想回显我正在调用的变量对象的名称,在这种情况下为controller_01。 我正在使用get_class,但不会打印变量名称,仅显示对象类型:(
<?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();


?> 
    
已邀请:
        你不能那样做。一个对象可以有多个引用,但是对象本身并不知道这些引用。 您唯一可以做的就是枚举您可以找到的每个变量,并检查它是否指向对象。但是这些引用也可以存在于数组或其他对象的属性中。 如果您需要对象以这种方式找到其参考变量,则设计确实存在缺陷。     

要回复问题请先登录注册