注意:数组转换为字符串 - 为什么?

Lee*_*Lee 3 php reference notice

您好我试图执行以下PHP代码,但我收到错误.我将引用传递给核心类,我想将其分配给类范围内的变量.

注意:数组到字符串转换

提前致谢..

$core = new core($config);
$core->execute();   
Run Code Online (Sandbox Code Playgroud)

class core
{
   private $config;

   public function __construct(&$config)
   {
      $this->$config = $config;
   }

   public function execute()
   {
      $this->set_path();
   }

   private function set_path()
   {
      return true;      
   }  
}
Run Code Online (Sandbox Code Playgroud)

Gut*_*tsy 12

好吧,首先....

$this->$config
Run Code Online (Sandbox Code Playgroud)

应该删除第二个$,$config因为否则它会尝试使用字符串中给出的名称来访问变量$config.(例如,如果$配置持有"test"的价值,你会访问"test"你的类内变化:$this->test)

$config无论如何,什么时候传入?(字符串,数组,对象等?)