写法一 class Test { private $a = 1; public function __get($name){ return $this->$name; } } echo (new Test())->a; ##写法二 class Test2 { private $a = 1; public function __get($name){ return $this->a; } } echo (new Test2())->a;