fork download
  1. <?php
  2.  
  3. // your code goes here
  4.  
  5. class News
  6. {
  7. public function exec($a)
  8. {
  9. return $this->$a();
  10. }
  11.  
  12. public function foo()
  13. {
  14. return 'foo';
  15. }
  16.  
  17. public function test()
  18. {
  19. return 'test';
  20. }
  21. }
  22.  
  23. try {
  24. $news = new News();
  25. echo $news->exec('foo1');
  26. } catch (Throwable $e) {
  27. var_dump($e);
  28. }
Success #stdin #stdout 0.02s 24560KB
stdin
Standard input is empty
stdout
object(Error)#2 (7) {
  ["message":protected]=>
  string(37) "Call to undefined method News::foo1()"
  ["string":"Error":private]=>
  string(0) ""
  ["code":protected]=>
  int(0)
  ["file":protected]=>
  string(21) "/home/uTtaKi/prog.php"
  ["line":protected]=>
  int(9)
  ["trace":"Error":private]=>
  array(1) {
    [0]=>
    array(6) {
      ["file"]=>
      string(21) "/home/uTtaKi/prog.php"
      ["line"]=>
      int(25)
      ["function"]=>
      string(4) "exec"
      ["class"]=>
      string(4) "News"
      ["type"]=>
      string(2) "->"
      ["args"]=>
      array(1) {
        [0]=>
        string(4) "foo1"
      }
    }
  }
  ["previous":"Error":private]=>
  NULL
}