1. 1、本文档共65页,可阅读全部内容。
  2. 2、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
  3. 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载
  4. 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-

文档评论(0)

asd522513656 + 关注
实名认证
内容提供者

该用户很懒,什么也没介绍

1亿VIP精品文档

相关文档