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

count_sentences[计算句数]

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

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}

输出结果:

Two Soviet Ships Collide - One Dies. Enraged Cow Injures Farmer with Axe.
2
这是一份简单的Smarty手册和Smarty教材,熟练掌握Smarty模板,让您做项目事半功倍