eval
mixed eval ( string $code_str )
把一段字符串以php脚本执行,字符串要注意单双引号,还有该字符串是要能以php执行的,不然会报错。
1 $string = 'cup';
2 $name = 'coffee';
3 $str = 'This is a $string with my $name in it.';
4 echo $str. "n";
5 eval("\$str = \"$str\";"); //$str="This is a $string with my $name in it.";
6 echo $str. "n";
2 $name = 'coffee';
3 $str = 'This is a $string with my $name in it.';
4 echo $str. "n";
5 eval("\$str = \"$str\";"); //$str="This is a $string with my $name in it.";
6 echo $str. "n";