smartprinter虚拟打印机phpsmarty模版引擎中变量操作符及使用方法

smartprinter虚拟打印机phpsmarty模版引擎中变量操作符及使用方法

内容导读

收集整理的这篇技术教程文章主要介绍了smartprinter虚拟打印机phpsmarty模版引擎中变量操作符及使用方法,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含2069字,纯文字阅读大概需要3分钟

内容图文

smarty常用的20个变量操作符 * 使用语法:{变量名|操作符:}
* capitalize ---首字母大写
* count_characters ---计算字符数
* cat ---连接字符串
* count_paragraphs ---计算段落数
* count_sentences ---计算句数
* count_words ---计算词数
* date_format ---时间格式
* default ---默认
* escape ---转码
* indent ---缩进
* lower ---小写
* nl2br ---换行符替换为
* regex_replace ---正则替换
* replace ---替换
* spacify ---插空
* string_format ---字符串格式化
* strip ---去除多余空格
* strip_tags ---去除html标签
* truncate ---截取
* upper ---大写
* wordwrap --约束行宽
使用方法:
index.php

代码如下:


include("smarty_inc.php");
$name = "My name is MaJi,age 22,sex boy.aaaaaa.";
$smarty->assign("title", $name);
$smarty->assign("row", $row);
$smarty->assign("d",strtotime("-0"));
$smarty->assign("nubmer", 342345.736524);
$smarty->display("index.html");
?>


index.html
原始数据:{$title}
使用capitalize变量操作符后:{$title|capitalize}
使用count_characters变量操作符后:{$title|count_characters}
使用cat变量操作符后:{$title|cat:"wwww.baidu.com"}
使用count_paragraphs变量操作符后:{$title|count_paragraphs}
使用count_sentences变量函数操作符后:{$title|count_sentences}
使用count_words变量函数操作后:{$title|count_words}
原始时间数据:{$d}
使用date_format变量函数操作:{$d|date_format:"%Y-%m-%d"}
使用smarty.now调用时间:{$smarty.now|date_format:"%Y-%m-%d"}
使用default变量函数操作:{$title1|default:"没有这个变量"}
使用escape变量函数操作:{$title|escape:"html"}
使用indent变量函数操作:{$title|indent:2:" "}
使用lower变量函数操作: {$title|lower}
使用upper变量函数操作:{$title|upper}
使用replace变量函数操作:{$title|replace:"is":"@@"}
使用spacify变量函数操作:{$title|spacify:"_"}
使用string_format变量函数操作:{$nubmer|string_format:"%.2f"}
使用strip变量函数操作:{$title|strip:"_"}
使用strip_tags变量函数操作:{$title|strip_tags}
使用truncate变量函数操作:{$title|truncate:30:"..."}
使用wordwrap变量函数操作:{$title|wordwrap:10:"
"}

以上就介绍了smartprinter虚拟打印机 php smarty模版引擎中变量操作符及使用方法,包括了smartprinter虚拟打印机方面的内容,希望对PHP教程有兴趣的朋友有所帮助。

内容总结

以上是为您收集整理的smartprinter虚拟打印机phpsmarty模版引擎中变量操作符及使用方法全部内容,希望文章能够帮你解决smartprinter虚拟打印机phpsmarty模版引擎中变量操作符及使用方法所遇到的程序开发问题。 如果觉得技术教程内容还不错,欢迎将网站推荐给程序员好友。

内容备注

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。


本文关键词:

联系我们

在线咨询:点击这里给我发消息

邮件:w420220301@qq.com