fork(9) download
  1. <?php
  2.  
  3. class toyota extends car {
  4. protected function drive() {
  5. echo "drive\n";
  6. }
  7. protected function dobreak() {
  8. echo "break\n";
  9. }
  10. }
  11.  
  12. class car {
  13. public function __call($name, $args)
  14. {
  15. if (method_exists($this, $name)) {
  16. $this->pre();
  17. return call_user_func_array(array($this, $name), $args);
  18. }
  19. }
  20.  
  21. function pre() {
  22. echo "pre\n";
  23. }
  24. }
  25.  
  26. $car = new toyota();
  27. $car->drive();
  28. $car->dobreak();
Success #stdin #stdout 0.02s 13112KB
stdin
Standard input is empty
stdout
pre
drive
pre
break