可将字符串之中的变量值代入,通常用在处理数据库的资料上。
函数处理后的字符串会沿续到 PHP 程序结束。
也就是说字符串中的$string变量用eval处理后再显示可以显示它的值,
例子已经很清楚了
第一个echo显示This is a $string with my $name in it.
第二个echo显示This is a cup with my coffee in it.
这还看不出区别吗?
函数处理后的字符串会沿续到 PHP 程序结束。
也就是说字符串中的$string变量用eval处理后再显示可以显示它的值,
例子已经很清楚了
第一个echo显示This is a $string with my $name in it.
第二个echo显示This is a cup with my coffee in it.
这还看不出区别吗?
$str = "This is a $string with my $name in it.";
echo $str;
得到的效果一样啊。
$str = 'This is a $string with my $name in it.';
echo $str. "\n";$string = 'cup';
$name = 'coffee';
eval("\$str1 = \"$str\";");
echo $str1. "\n";$string = 'test';
$name = 'you';
eval("\$str1 = \"$str\";");
echo $str1. "\n";
?>
这样是否好理解点?
<!-- 1 -->
$etc = "include('wo"."kao.inc');";eval($etc);<!-- 2 -->
include('wokao.inc');
以上1和2是相等的
echo $a;
eval('$a=5');
echo $a;
如
$word = "hello";
echo "$word, world!"; //得到 hello, world!echo '$word, world!'; //得到 $word, world!
eval("\$str1 = \"$str\";");这一句和
$str1 = "This is a $string with my $name in it.";是不是等价的?to:gaofaq(老高)
$etc = "include('wo"."kao.inc');";
eval($etc);
这样就可以了吗?不用输出?eval()是不是和repuire()一样,在他出现的地方被他指定的文本替换?不知道我这样理解对不对?