当前位置: 首页 > 图文教程 > 网络编程 > PHP > smarty笔记--模板参数

PHP
PHP新手总结的PHP基础知识
php实现gb2312和unicode间编码转换
用php语言实现数据库连接详细代码介绍
详细解析 PHP 向 MySQL 发送数据过程
利用PHP V5开发多任务应用程序
详细讲解PHP中缓存技术的应用
php escapeshellcmd多字节编码漏洞
《PHP设计模式介绍》导言
《PHP设计模式介绍》第一章 编程惯用法
《PHP设计模式介绍》第二章 值对象模式
《PHP设计模式介绍》第三章 工厂模式
《PHP设计模式介绍》第四章 单件模式
《PHP设计模式介绍》第五章 注册模式
《PHP设计模式介绍》第六章 伪对象模式
《PHP设计模式介绍》第七章 策略模式
《PHP设计模式介绍》第八章 迭代器模式
《PHP设计模式介绍》第九章 观测模式
《PHP设计模式介绍》第十章 规范模式
《PHP设计模式介绍》第十一章 代理模式
《PHP设计模式介绍》第十二章 装饰器模式

PHP 中的 smarty笔记--模板参数


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-10-19   浏览: 169 ::
收藏到网摘: n/a

1.capitalize(使字符串的首字母大写)
$smarty->assign("str", "my name is crazybaby");
{$str|capitalize}=>My Name Is Crazybaby.
ps:当字母中包含数字时 首字母不会大写!

2.cat:(相当于字符串相加)
$smarty->assign("str",'My name is:');
{$str|cat:"Crazybaby"}=>My name is Crazybaby.

3.date_format(不用说,字面意思是格式化日期)
$smarty->assign('str',"公元");
{$str|date_format:"%Y年%月%d日"}=>公元2009年4月26日
{$Smarty.now|date_format:'%Y-%m-%d'}

4.default(它显示默认值)
{$str|default:"没有值"}->没有值

5.indent(让它缩进8个空白字母位,并使用"*"取替这8个空白字符)
$smarty->assign("str5", "前边8个*");
{$str|indent:8:"*"}->********前边8个*

6.lower(转换小写)
$smarty->assign('str',[email protected])
{$str|lower}->[email protected]

7.replace(替换)
$smarty->assign('str',Hi,baby)
{$str|replace:"baby":"crazybaby"}

8.truncate()
{$name|truncate:10:"..."}超过十个字符用。。。表示

9.count_characters(计算字符数)

10.count_paragrphs(计算段落数)->它是按照回车区分段落的

11.count_sentences(计算句子数)

12.count_word(计算单词数)

13.escape(转码)可以把html代码转换成普通文本。等如:
{$name|escape:'url'}->
$value="asdasdasd";
$smarty->assign('name',$value);