__get导致“无法通过引用分配重载对象”

时间:2014-10-23 06:42:57

标签: php overloading getter

class a
{
}

class b
{
  public function __get($name)
  {
     // Do nothing
  }
}

// Works
$a = new a;
$x = new StdClass();
$a->test =& $x;

// Fatal error:  Cannot assign by reference to overloaded object on line 21
$b = new b;
$y = new StdClass();
$b->test =& $y;

魔法吸气剂的存在如何以及为何会导致此错误?

0 个答案:

没有答案