变量可以作为方法名吗?该怎么处理
变量可以作为方法名吗?
大概意思就是上面的代码
请问下有什么方法可以达到这个效果
就是想根据变量的值,不加判断直接调用对应的方法
------解决方案--------------------
- 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";
}