fork(40) download
  1. <?php
  2.  
  3. class test {
  4. function __construct(){}
  5.  
  6. private function test1(){
  7. echo "In test1", PHP_EOL;
  8. }
  9. private function test2(){
  10. echo "test2", PHP_EOL;
  11. }
  12. protected function test3(){
  13. return "test3" . PHP_EOL;
  14. }
  15. public function __call($method,$arguments) {
  16. if(method_exists($this, $method)) {
  17. $this->test1();
  18. return call_user_func_array(array($this,$method),$arguments);
  19. }
  20. }
  21. }
  22.  
  23. $a = new test;
  24. $a->test2();
  25. echo $a->test3();
  26. /*
  27.  * Output:
  28.  * In test1
  29.  * test2
  30.  * In test1
  31.  * test3
  32.  */
Success #stdin #stdout 0.02s 52472KB
stdin
Standard input is empty
stdout
In test1
test2
In test1
test3