将值代入字串之中。
语法: void eval(string code_str);
传回值: 无
函式种类: 资料处理
本函式可将字串之中的变数值代入,通常用在处理资料库的资料上。参数 code_str 为欲处理的字串。值得注意的是待处理的字串要符合 PHP 的字串格式,同时在结尾处要有分号。使用本函式处理后的字串会沿续到 PHP 程式结束。
<?php$string = '杯子';$name = '咖啡';$str = '这个 $string 中装有 $name.<br>';echo $str;eval( "\$str = \"$str\";" );echo $str;?>本例的传回值为这个 $string 中装有 $name.这个 杯子 中装有 咖啡.