smarty display和fetch的区别 简单

转自:http://blog.sina.com.cn/s/blog_610997850100sxz8.html

<?php
include_once 'init_smarty.php';

$smarty->assign('title','标题');
$smarty->assign('content','内容');

$output = $smarty->fetch('index.html');

echo $output;
// $smarty->display('index.html');
?>

使用fetch函数,你可以将要输出的html赋值给一个变量,可以对里面的数据进行一些输出,再将他输出。
smarty中的display方法,实际上调用的就是fetch,只不过是直接将他显示出来而已,而fetch默认是不显示,返回给一个变量的。

原文地址:https://www.cnblogs.com/chyong168/p/2256073.html