HBcms是一个用Pear框架+Smarty模板引擎构架的cms项目,欢迎大家参与制作Smarty模板

count_characters[字符计数]

Parameter Position Type Required Default Description
1 boolean No false This determines whether or not to include whitespace characters in the count.
决定是否计算空格字符。

This is used to count the number of characters in a variable.
计算变量里的字符数

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
这是一份简单的Smarty手册和Smarty教材,熟练掌握Smarty模板,让您做项目事半功倍