真的快看不懂楼主的意思了,如果要从数据库中读取数据,然后进行输出
用不用include()都可以呀就是直接连接数据库,按条件读取数据,然后进行数据的显示不知道楼主是什么问题

解决方案 »

  1.   

    不是的,include()函数,是包含一个文件进来,然后就可以做为php代码,在php页面执行
    但如果是从数据库取出来,就只是个变量,无法变成代码执行的!
      

  2.   

    你如果要得到php的变量,就直接进行传递就可以了呀,不知道楼主的问题,可以搞点代码放在上面让我看看噻,要不我真的不知道你的意思
      

  3.   

    楼主这样
    <?php
    $string = 'cup';
    $name = 'coffee';
    $str = 'This is a $string with my $name in it.';
    echo $str. "\n";
    eval("\$str = \"$str\";");
    echo $str. "\n";
    ?> 
    $str就是你从数据库取出的内容
    你也可以用模板,smarty
      

  4.   

    楼主的意思是这样的吧,数据库中存放的不是普通的数据,而是php代码
    楼主想把它取出来并且执行。
    但是 我不知道答案是什么
      

  5.   

    楼主到底是要include()包含的文件执行还是不执行呢?贴代码出来问题好解决些!
      

  6.   

    to lanxk(蓝) 没错,就是你说的这样!我的确是要从数据库中取出php
    代码执行,但从数据库中取出来,就是一个变量,我不知道如何执行它,所以请教各位!
      

  7.   

    To dhlxmy():你的意思我明白,我也很关心这个问题,我一直不知道怎么解决,据我了解在phpx里有人会,但就是不愿意说出来,你算了吧。
      

  8.   

    eval -- Evaluate a string as PHP code
    Description
    mixed eval ( string code_str)
    eval() evaluates the string given in code_str as PHP code. Among other things, this can be useful for storing code in a database text field for later execution. There are some factors to keep in mind when using eval(). Remember that the string passed must be valid PHP code, including things like terminating statements with a semicolon so the parser doesn't die on the line after the eval(), and properly escaping things in code_str. Also remember that variables given values under eval() will retain these values in the main script afterwards. A return statement will terminate the evaluation of the string immediately. In PHP 4, eval() returns NULL unless return is called in the evaluated code, in which case the value passed to return is returned. In PHP 3, eval() does not return a value. 
    //手册中的,看关键的句子:将给定的php代码字符串执行,......这对于将PHP代码存放在数据库文本字段中供以后执行是非常有用的。。
      

  9.   

    uuq(杜牧) 谢谢,你说的对,是我没明白是要用eval()函数,hehe 
    非常感谢ice_berg16(寻梦的稻草人)更明确地说明了问题!谢谢大家帮助!