$name; function hello(){ echo "hello word"; } 大概意思就是上面的代码 请问下有什么方法可以达到这个效果 就是想根据变量的值,不加判断直接调用对应的方法 ------解决方案-------------------- PHP code复制 $name="hello"; $name(); function 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";
}

相关文章