fork download
  1. <?php
  2.  
  3. class Hello
  4. {
  5. final public function speak($name)
  6. {
  7. echo 'Non-Static called';
  8.  
  9. return 'Hello ' . $name;
  10. }
  11.  
  12. final public static function __callStatic($method, array $params)
  13. {
  14. echo 'Static called';
  15.  
  16. if (method_exists(__CLASS__, $method) === false) {
  17. $message = sprintf(
  18. 'Call to undefined method %s::%s()',
  19. get_called_class(),
  20. $method
  21. );
  22. throw new \UnexpectedValueException($message);
  23. }
  24.  
  25. return call_user_func_array([new static, $method], $params);
  26. }
  27. }
  28.  
  29.  
  30. echo Hello::speak('world'); // Hello world
  31.  
  32.  
Success #stdin #stdout 0.02s 23472KB
stdin
Standard input is empty
stdout
Non-Static calledHello world