4,251
社区成员
发帖
与我相关
我的任务
分享
$smarty = new Smarty;
$smarty->allow_php_tag=true;
$smarty->assign("a", "aaaaaaaaaaaaaa");
$smarty->display('index.tpl');
//php文件中这样写
global $var;//申明全局变量
...
$var = 'Hi Smarty';//赋值,无需再使用smarty的assign方法
//模板中这样获取
<{php}>echo $GLOBALS['var'];<{/php}>