<?php
class MinhaClasse {
var $foo = 'ola mundo' ;
var $bar = 'teste para o stack' ;
public function index( $fn = a)
{
echo $this -> $fn ( ) ; // <-- é isso que eu quero
}
private function a( )
{
return $this -> foo ;
}
private function b( )
{
return $this -> bar ;
}
}
$classe = new MinhaClasse( ) ;
$classe -> index ( ) ;
$classe -> index ( b) ;
PD9waHAKY2xhc3MgTWluaGFDbGFzc2UgewogICAgdmFyICRmb28gPSAnb2xhIG11bmRvJzsKICAgIHZhciAkYmFyID0gJ3Rlc3RlIHBhcmEgbyBzdGFjayc7CiAgICBwdWJsaWMgZnVuY3Rpb24gaW5kZXgoJGZuID0gYSkKICAgIHsKICAgICAgICBlY2hvICR0aGlzLT4kZm4oKTsgLy8gPC0tIMOpIGlzc28gcXVlIGV1IHF1ZXJvCiAgICB9CiAgICBwcml2YXRlIGZ1bmN0aW9uIGEoKQogICAgewogICAgICAgIHJldHVybiAkdGhpcy0+Zm9vOwogICAgfQogICAgcHJpdmF0ZSBmdW5jdGlvbiBiKCkKICAgIHsKICAgICAgICByZXR1cm4gJHRoaXMtPmJhcjsKICAgIH0KfQokY2xhc3NlID0gbmV3IE1pbmhhQ2xhc3NlKCk7CiRjbGFzc2UtPmluZGV4KCk7CiRjbGFzc2UtPmluZGV4KGIpOwo=