count_characters
count_characters 用于计算变量中的字符数。
基本用法
{$myVar|count_characters}
参数
| 参数 | 类型 | 必需 | 描述 |
|---|---|---|---|
| 1 | 布尔类型 | 否 | 决定是否包括空格字符在内进行计数。 |
示例
<?php
$smarty->assign('articleTitle', 'Cold Wave Linked to Temperatures.');
模板代码如下:
{$articleTitle}
{$articleTitle|count_characters}
{$articleTitle|count_characters:true}
输出结果:
Cold Wave Linked to Temperatures.
29
33
另请参阅 count_words、
count_sentences 和
count_paragraphs。