1--TEST-- 2__call() for private/protected methods 3--FILE-- 4<?php 5 6class A { 7 private $var1 = 'var1 value'; 8 protected $var2 = 'var2 value'; 9 10 private function func1() 11 { 12 return "in func1"; 13 } 14 protected function func2() 15 { 16 return "in func2"; 17 } 18 public function __get($var) 19 { 20 return $this->$var; 21 } 22 public function __call($func, array $args = array()) 23 { 24 return call_user_func_array(array($this, $func), $args); 25 } 26} 27 28$a = new A(); 29echo $a->var1,"\n"; 30echo $a->var2,"\n"; 31echo $a->func1(),"\n"; 32echo $a->func2(),"\n"; 33 34?> 35--EXPECT-- 36var1 value 37var2 value 38in func1 39in func2 40