- 1、本文档共65页,可阅读全部内容。
- 2、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
- 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
smarty重点
Example 5-2. capitalize例 5-2.首字大写
index.php:
$smarty = new Smarty;
$smarty-assign(articleTitle, Police begin campaign to rundown jaywalkers.);
$smarty-display(index.tpl);
index.tpl:
{$articleTitle}
{$articleTitle|capitalize}
OUTPUT:
Police begin campaign to rundown jaywalkers.
Police Begin Campaign To Rundown Jaywalkers.
Example 5-3. count_characters
index.php:
$smarty = new Smarty;
$smarty-assign(articleTitle, Cold Wave Linked to Temperatures.);
$smarty-display(index.tpl);
index.tpl:
{$articleTitle}
{$articleTitle|count_characters}
{$articleTitle|count_characters:true}//决定是否计算空格
OUTPUT输出:
Cold Wave Linked to Temperatures.
29
33
Example 5-4. cat 将cat里的值连接到给定的变量后面.
index.php:
$smarty = new Smarty;
$smarty-assign(articleTitle, Psychics predict world didnt end);
$smarty-display(index.tpl);
index.tpl:
{$articleTitle|cat: yesterday.}
OUTPUT:
Psychics predict world didnt end yesterday.
Example 5-5. count_paragraphs 计算变量里的段落数量。index.php:
$smarty = new Smarty;
$smarty-assign(articleTitle, War Dims Hope for Peace. Childs Death Ruin Couples Holiday.\n\nMan is Fatally Slain. Death Causes Loneliness, Feeling of Isolation.);
$smarty-display(index.tpl);
index.tpl:
{$articleTitle}
{$articleTitle|count_paragraphs}
OUTPUT:
War Dims Hope for Peace. Childs Death Ruins Couples Holiday.
Man is Fatally Slain. Death Causes Loneliness, Feeling of Isolation.
2
Example 5-6. count_sentences 计算变量里句子的数量index.php:
$smarty = new Smarty;
$smarty-assign(articleTitle, Two Soviet Ships Collide - One Dies. Enraged Cow Injures Farmer with Axe.);
$smarty-display(index.tpl);
index.tpl:
{$articleTitle}
{$articleTitle|count_sentences}
OUTPUT:
Two Soviet Ships Collide - One Dies. Enraged Cow Injures Farmer with Axe.
2
Example 5-7. count_words 计算变量里的词数
index.php:
$smarty = new Smarty;
$smarty-assign(articleTitle, Dealers Will Hear Car Talk at Noon.);
$smarty-display(index.tpl);
index.tpl:
{$articleTitle}
{$articleTitle|count_words}
OUTPUT:
Dealers Will Hear Car Talk at Noon.
7
Example 5-
您可能关注的文档
- 5 施工现场临时用电及用电机具的安全管理规定.doc
- 精忠岳飞-剧情.doc
- 公司抬头信签纸.pdf
- 济宁一模地理部分.doc
- 网络复习0.doc
- CATIA工程图-201202.doc
- 初中信息技术第一.doc
- 新塘路、天城路下穿铁路通道概况.doc
- 桂林旅游攻略及景点概况.doc
- 脚手架搭拆方案3.doc
- 家居用品电商本土化营销策略与用户体验研究报告.docx
- 城市垃圾填埋场封场治理2025年社会稳定风险评估与社区志愿服务报告.docx
- 2025年在线医疗医生激励策略与平台运营效率优化报告.docx
- 宠物医疗行业发展趋势及2025年市场规模预测报告.docx
- 元宇宙技术与文化创意产业跨界融合创新案例解析.docx
- 聚焦2025年:保险行业气候风险产品创新与保险市场风险防范.docx
- 2025年自动驾驶商用车在快递运输中的应用场景报告.docx
- 深入探讨海底捞2025年餐饮服务创新与行业产业链研究报告.docx
- 2025年智慧校园教学资源平台建设与教育资源共享平台融合策略.docx
- 2025至2030年中国餐具消毒盒市场现状分析及前景预测报告.docx
文档评论(0)