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

count_words[计算词数]

This is used to count the number of words in a variable.
计算变量里的词数 。

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}

输出结果:

Dealers Will Hear Car Talk at Noon.
7
这是一份简单的Smarty手册和Smarty教材,熟练掌握Smarty模板,让您做项目事半功倍