count_characters

计算变量内容里有多少个字符。

参数顺序 类型 必选参数 默认值 说明
1 boolean No FALSE 计算总数时是否包括空格字符。


Example 5.4. count_characters

  1. <?php
  2.  
  3. $smarty->assign('articleTitle', 'Cold Wave Linked to Temperatures.');
  4.  
  5. ?>
  6.  

模板:

  1. {$articleTitle}
  2. {$articleTitle|count_characters}
  3. {$articleTitle|count_characters:true}
  4.  

输出:

  1. Cold Wave Linked to Temperatures.
  2. 29
  3. 33
  4.  

参见 count_words, count_sentencescount_paragraphs.

原文: https://www.smarty.net/docs/zh_CN/language.modifier.count.characters.tpl