我正在查看一些代码用于工作,并遇到了这一行:
eval("\$element = \"$element\";");
我真的很困惑为什么任何PHP开发人员都会编写这一行.除了为自己设置变量之外,这还有什么用途?
<?PHP $string = 'cup'; $name = 'coffee'; $str = 'This is a $string with my $name in it.'; echo $str. "\n"; eval("\$str = \"$str\";"); echo $str. "\n"; ?>
以上示例将输出:
This is a $string with my $name in it. This is a cup with my coffee in it.
http://php.net/manual/en/function.eval.php
我只是ctl c ctrl v 原文链接:https://www.f2er.com/php/134901.html