关于使用smarty如何将输出存为变量

maskdata 2010-07-17 08:57:37
test.php:

$tpl=new Smarty;
$tpl->assign('a','lily');
$tpl->assign('b','eric');

$tpl->display('test.tpl');

----------------------------------
test.tpl
<html>
<body>
my Name is:{$a}<br/>
your Name is:{$b}
</body>
</html>

如上的2个文件
我如何将$tpl->display('test.tpl')的输出内容不输出只保存到变量呢

想得到的结果是类似于这样的一个字符串
"<html><body>my Name is:lily<br/>your Name is:Eric</body></html>"

smarty有没有这种函数呢.如
$html_string=smarty->某方法('test.tpl');
...全文
47 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
YY_072 2010-07-24
  • 打赏
  • 举报
回复
...
床上等您 2010-07-17
  • 打赏
  • 举报
回复
$smarty->assign('a','b');
$html_content=$smarth->fetch('test_tmp');
//fetch 这个方法可以实现。

21,886

社区成员

发帖
与我相关
我的任务
社区描述
从PHP安装配置,PHP入门,PHP基础到PHP应用
社区管理员
  • 基础编程社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧