如何让数据库字段中的php代码运行?

解决方案 »

  1.   

    一般用 eval 函数就可以了
      

  2.   

    抄了个例子,你看看<?php
    $string = "beautiful";
    $time = "winter";$str = 'This is a $string $time morning!';
    echo $str. "<br />";eval("\$str = \"$str\";");
    echo $str;
    ?> 
    输出结果:This is a $string $time morning!
    This is a beautiful winter morning! 
      

  3.   

    在当前php程序中读出代码所在的字段内容,生成另外一个.php,再跳转到该文件。
      

  4.   

    直接取出来,放到页面显示就可以了,$row['part_code']
      

  5.   

    假如 数据库字段取出来值为 变量 $phpcode
    eval($phpcode);