我正在尝试像那样使用 eval() 函数:
$foo = 'eval';
$bar = 'echo 1;';
$foo($bar);
但我收到一个错误: fatal error :调用未定义的函数 eval()
这很奇怪,因为下面的代码是有效的
$foo = 'base64_encode';
$bar = 'foobar';
echo $foo($bar);
有人可以帮忙吗?
最佳答案
Note: Because this is a language construct and not a function, it cannot be called using variable functions.
点击注释中的链接,您还将找到:
Variable functions won't work with language constructs such as
echo
,unset()
,isset()
,empty()
,include
,require
and the like. Utilize wrapper functions to make use of any of these constructs as variable functions.
关于php - 未定义函数 eval() - PHP,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29707896/