您的位置:首页 > 其它

smarty_smarty中条件语句if的使用和文字处理interal忽略其内部所有字符

2011-01-02 13:36 495 查看
smarty中条件语句if的使用和文字处理interal忽略其内部所有字符

一、条件语句if的使用
1、if.php内容如下:
<?php
/*
*条件语句if的使用
*/
include("smarty_inc.php");
$name="Hello,Smarty!";
$smarty->assign("display",$name);
$smarty->display("if.htm");
?>
2、templantes/if.htm内容如下:
{if $display==''}
"$display"为空,
什么都没有啊!
{else}
{$display}
{/if}
运行结果如下:
Hello,Smarty!

二、文字处理interal忽略其内部所有字符
1、interal.php内容如下:
<?php
/*
*literal忽略其内部的所有字符,这样可以让其内部的javascript脚本正常运行
*/
include("smarty_inc.php");
$smarty->display("literal.htm");
?>
2、interal.htm内容如下:
{literal}
<script language=javascript>
<!--
function alert_succes(){
alert("javascript函数运行成功!");
}
alert_succes();
//-->
</script>
{/literal}
运行结果:弹出一个对话框,对话框显示"javascript函数运行成功!"
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐