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

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

WBOY
Release: 2016-06-13 13:28:55
Original
1113 people have browsed it

变量可以作为方法名吗?

PHP code
<!--

Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/

-->
$name="hello()";
$this->$name;
function hello(){
echo "hello word";
}

Copy after login

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

------解决方案--------------------
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>
Copy after login
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template