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

首页  >  文章  >  后端开发  >  变量可以作为方法名吗?该怎么处理

变量可以作为方法名吗?该怎么处理

WBOY
WBOY原创
2016-06-13 10:26:14867浏览

变量可以作为方法名吗?

PHP code
<!--Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->$name="hello()";$this->$name;function hello(){echo "hello word";}

大概意思就是上面的代码
请问下有什么方法可以达到这个效果
就是想根据变量的值,不加判断直接调用对应的方法

------解决方案--------------------
PHP code
$name="hello";$name();function hello(){echo "hello word";}<br><font color="#e78608">------解决方案--------------------</font><br>$name="hello()";<br>eval("return $name;");<br><br>function hello(){<br>echo "hello word";<br>}<div class="clear">
                 
              
              
        
            </div>
声明:
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn