Variable Modifiers [变量调节器]

1.capitalize    首字母大写

eg:capitalize.php //***php文件

<?php
include 'libs/Smarty.class.php';
$smarty=new Smarty();
$smarty->template_dir="demo/templates";//设置模版目录
$smarty->compile_dir="demo/templates_c";//设置编译目录
//***********************************
//设置定界符
//*************************
$smarty->left_delimiter="<{";
$smarty->right_delimiter="}>";
$ac="hello world";
$smarty->assign('ack',$ac);

$smarty->display("capitalize.tpl");

?>

capitalize.tpl //****模版文件

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
</head>

<body>

<{$ack|capitalize}>;
</body>
</html>

2、count_characters[字符计数]

eg:count_characters.php //***php文件

<?php
include 'libs/Smarty.class.php';
$smarty=new Smarty();
$smarty->template_dir="demo/templates";//设置模版目录
$smarty->compile_dir="demo/templates_c";//设置编译目录
//***********************************
//设置定界符
//*************************
$smarty->left_delimiter="<{";
$smarty->right_delimiter="}>";
$ac="hello world";
$smarty->assign('ack',$ac);

$smarty->display("count_characters.tpl");

?>

count_characters.tpl //****模版文件

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
</head>

<body>

<{$ack|count_characters}>;//字符计数不计空格

<{$ack|count_characters:true}>;//字符计数算上空格
</body>
</html>

3、cat[连接字符串]

eg.同上 代码相同   不同点是

<{$ack|cat:"***"}>  //实现效果是:实现hello world***

4、count_paragraphs[计算段数]   //计算变量里的段落数量。

5、count_sentences[计算句数]    //计算变量里句子的数量。

6、count_words[计算词数]          //计算变量里的词数。

7.date_format[格式化日期]           //

<{$smarty.now|date_format:"%A, %B %e, %Y"}>;

<{$smarty.now|date_format:"%H:%M:%S"}>;

<{$yesterday|date_format:"%A, %B %e, %Y"}>

程序员提示:date_format本质上是php的strftime()函数的一个包装。
当php被编译的时候你可以或多或少的依靠系统的strftime()转换有效的区分符。
***关于区分符*可以查看系统手册的有效区分符的全表.

8、default[默认值]     //这是变量为空的时候的默认输出(当没有变量的值的时候就按默认的输出)。

eg、<{$myTitle|default:"no title"}>

9、escape[编码]    //使用何种编码格式。




  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值