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函数运行成功!"
一、条件语句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函数运行成功!"
相关文章推荐
- HTML中Smarty中的if语句条件修饰词eq相等ne、neq不相等,gt大于,lt小于
- 【算法题】题目:求1+2+…+n,要求不能使用乘除法、for、while、if、else、switch、case等关键字以及条件判断语句(A?B:C)
- 求1+2+3+...+n,要求不能使用乘除法、for、while、if、else、switch、case等关键字及条件判断语句(A?B:C)。
- Shell使用if条件语句
- 求1+2+…+n, 要求不能使用乘除法、for、while、if、else、switch、case等关键字以及条件判断语句(A?B:C)
- Smarty模板技术if语句中使用的比较修饰符号
- 剑指Offer(Java版): 求1+2+3+...+n,要求不能使用乘除法、for、while、if、else、switch、case等关键字及条件判断语句(A?B:C)。
- 题目:求1+2+…+n,要求不能使用乘除法、for、while、if、else、switch、case等关键字以及条件判断语句(A?B:C)
- 求1+2+3+...+n,要求不能使用乘除法、for、while、if、else、switch、case等关键字及条件判断语句(A?B:C)。
- 求1+2+3+...+n,要求不能使用乘除法、for、while、if、else、switch、case等关键字及条件判断语句(A?B:C)
- Shell 脚本基础 - 使用 if 语句进行条件检测
- 求1+2+3+...+n,要求不能使用乘除法,for,while,if,else,switch,case等关键字以及条件判断语句
- 求1+2+3+...+n,要求不能使用乘除法、for、while、if、else、switch、case等关键字及条件判断语句(A?B:C)。
- 求1+2+3+...+n,要求不能使用乘除法、for、while、if、else、switch、case等关键字及条件判断语句(A?B:C)
- Go语言中的if条件语句使用详解
- js在if else语句中var的变量在条件语句外可以使用吗?
- 1+2+3+...+n,要求不能使用乘除法、for、while、if、else、switch、case等关键字及条件判断语句(A?B:C)
- 求1+2+3+...+n,要求不能使用乘除法,for,while,if,else,switch,case等关键字以及条件判断语句
- 【C语言基础】一直接收键盘字符 (while 循环,if条件语句)
- Shell 脚本基础 - 使用 if 语句进行条件检测