你可以看看手册中的例子:Example 1. eval() example - simple text merge <?php $string = 'cup'; $name = 'coffee'; $str = 'This is a $string with my $name in it.<br>'; echo $str; eval ("\$str = \"$str\";"); echo $str; ?> The above example will show: This is a $string with my $name in it. This is a cup with my coffee in it.
就算不合法,只是在显示的时候是乱的,但也不会不通过呀。你可以试验一下。拜托xuzuning(唠叨) 帮帮忙
$string = 'cup';
$name = 'coffee';
$str = 'This is a $string with my $name in it.<br>';
echo $str;
eval ("\$str = \"$str\";");
echo $str;
?>
The above example will show:
This is a $string with my $name in it.
This is a cup with my coffee in it.
eval ("\$output = \"$data\";");
}
<?php
$array1 = array("abc",123);
foreach($array1 AS $key => $data){
eval ("\$output = \"$data\";");
echo "$output<br>";
}
?>
输出
abc
123