如何使eval()无法访问某些变量

时间:2014-05-23 15:38:41

标签: php variables eval

例如,如果我有这个PHP代码

$template = 'A = {$a}, b = {$b}';
$a = "A";
$b = "B";

eval("\$output = \"".$template."\";");

echo $output;

结果为A = A, b = B。但如果我不希望eval()解析var $ b(不使用unset()),我该怎么办?

0 个答案:

没有答案