文章目录[隐藏]
如何让数据库字段中的php代码运行?
回复讨论(解决方案)
一般用 eval 函数就可以了
没明白什么问题
抄了个例子,你看看
<?php
$string = “beautiful”;
$time = “winter”;
$str = ‘This is a $string $time morning6本文来源gao@dai!ma.com搞$代^码!网7
搞gaodaima代码
!’;
echo $str. “
“;
eval(“\$str = \”$str\”;”);
echo $str;
?>
输出结果:
This is a $string $time morning!
This is a beautiful winter morning!
在当前php程序中读出代码所在的字段内容,生成另外一个.php,再跳转到该文件。
直接取出来,放到页面显示就可以了,$row[‘part_code’]
假如 数据库字段取出来值为 变量 $phpcode
eval($phpcode);