如何使用指针来访问类的内部变量
1 class talker { 2 private $data = 'Hi'; 3 public function &get() { 4 return $this->data; 5 } 6 public function out() { 7 var_dump($this->data); 8 } 9 } 10 11 $aa = new talker(); 12 $d = &$aa->get(); 13 14 $d = array('You'); 15 $aa->out();
1 ---------- PHP ---------- 2 array(1) { 3 [0]=> 4 string(3) "You" 5 } 6 输出完成 (耗时 0 秒) - 正常终止