各位好:
当使用了SMARTY后,我们有时需要在程序中直接echo信息,而不是使用$smarty->assign方法来赋值了,假如我们有一个模板:index.tpl.html <html>
.....
<body><!--{$conshow}--></body>
</html>复制代码
我们的程序代码是: <?php
...
if(..){
echo '<script>.....</script>';
}else{
$smarty->assign('conshow','内容....');
}
$smarty->display('index.tpl.html');
...
?>复制代码如果这样的话,解析后的页面会很不规范:程序直接echo的信息会出现在<html>之前,请问各位同仁是如何解决这种情况的??
当使用了SMARTY后,我们有时需要在程序中直接echo信息,而不是使用$smarty->assign方法来赋值了,假如我们有一个模板:index.tpl.html <html>
.....
<body><!--{$conshow}--></body>
</html>复制代码
我们的程序代码是: <?php
...
if(..){
echo '<script>.....</script>';
}else{
$smarty->assign('conshow','内容....');
}
$smarty->display('index.tpl.html');
...
?>复制代码如果这样的话,解析后的页面会很不规范:程序直接echo的信息会出现在<html>之前,请问各位同仁是如何解决这种情况的??
如:
aaa.html code<script>alert('')</script><html>...</html>
...
if(..){
$smarty->assign('flag','1');//在模板文件中判断然后输出 这样能不能符合你的要求?
}else{
$smarty->assign('flag','0');
$smarty->assign('conshow','内容....');
}
$smarty->display('index.tpl.html');
...
?>
alert('页面加载完毕后输出!');
})
...
if(..){
$smarty->assign('conshow','内容....');
}
$smarty->display('index.tpl.html');
if(..){
echo '<script>.....</script>';
}
...
?>