变量可以作为方法名吗?PHP code$namehello()$this-$namefunction hello(){echo hello word}大概
变量可以作为方法名吗?
- PHP code
$name="hello()";$this->$name;function hello(){echo "hello word";}大概意思就是上面的代码
请问下有什么方法可以达到这个效果
就是想根据变量的值,不加判断直接调用对应的方法
[解决办法]
- PHP code
$name="hello";$name();function hello(){echo "hello word";}
[解决办法]
$name="hello()";
eval("return $name;");
function hello(){
echo "hello word";
} 