fork download
  1. <?php
  2.  
  3. class A {
  4. public function foo() {
  5. echo 'foo' . PHP_EOL;
  6. }
  7.  
  8. public function bar() {
  9. echo 'bar' . PHP_EOL;
  10. }
  11.  
  12. public function execute($f) {
  13. $this->$f();
  14. }
  15. }
  16.  
  17. $o = new A;
  18.  
  19. $o->execute('foo');
  20. $o->execute('bar');
  21.  
Success #stdin #stdout 0.03s 52480KB
stdin
Standard input is empty
stdout
foo
bar