2012-06-06 70 views
0

我试图做到这一点:PHP将函数的输出保存在变量中?

$productlist= $tpl->draw('products'); 

后来我想呼应它的其他一些文件:

而$ tpl->画(“产品”)中显示的一些输出例如

<div id="productlist> 
include("products"); 
</div> 
+0

究竟什么是你的问题? – dpk2442

+0

$ tryt ='

include("products");
'; echo $ tryt;这是工作我猜,使用会话来存储或保存在分贝 – swapnesh

回答

0

您可以使用会话变量将数据公开到另一个脚本中,或者从数据库或平面文件中存储和检索数据。

0

试试这个

$productlist= $tpl->draw('products'); 

//类文件

class drawing{ 

    function draw($type) { 

    $str=''; 

    if($type=='') 
    $type='default' 

    $ids=$type.'list'; 

    $str="<div id='$ids'> include('$type') </div>"; 
    return $str; 
} 
}