fork(2) download
  1. <?php
  2. class MinhaClasse {
  3. var $foo = 'ola mundo';
  4. var $bar = 'teste para o stack';
  5. public function index($fn = a)
  6. {
  7. echo $this->$fn(); // <-- é isso que eu quero
  8. }
  9. private function a()
  10. {
  11. return $this->foo;
  12. }
  13. private function b()
  14. {
  15. return $this->bar;
  16. }
  17. }
  18. $classe = new MinhaClasse();
  19. $classe->index();
  20. $classe->index(b);
  21.  
Success #stdin #stdout #stderr 0.03s 52480KB
stdin
Standard input is empty
stdout
ola mundoteste para o stack
stderr
PHP Notice:  Use of undefined constant a - assumed 'a' in /home/vzhIwj/prog.php on line 5
PHP Notice:  Use of undefined constant b - assumed 'b' in /home/vzhIwj/prog.php on line 20