喜悦国际村 » PHP高级编程 » 在smarty模板中的一个问题

页: [1]
hlmhlm2006-9-29 09:13 AM
在smarty模板中的一个问题

$smarty->display('index.tpl');在段代码大家都知道可以把解释完的模板输出,我现在不想输出,想把它赋值给一个变量,怎么做呀,老大们?:(

fmfsaisai2006-9-29 03:09 PM
方法1
-------------------------------------------
ob_start();
$smarty->display('index.tpl');
$content=ob_get_contents();
ob_end_clean();
方法2
--------------------------------------------
ob_start();
$file=$smarty->_get_compile_path('index.tpl');
include($file);
$content=ob_get_contents();
ob_end_clean();

后者效率高些

hlmhlm2006-9-29 03:37 PM
谢了!先试一下

谢了!先试一下

只爱一个人2006-9-29 06:55 PM
$smarty->fetch


查看完整版本: 在smarty模板中的一个问题


Powered by Discuz! Archiver 6.1.0  © 2001-2006 Comsenz Inc.
Processed in 0.0199 second(s), 2 queries