<table summary="Header navigation table" width="100%" border="0" cellpadding="0" cellspacing="0"><tr><th colspan="3" align="center">Smarty - the compiling PHP template engine</th></tr><tr><td width="25%" align="left" valign="bottom"><a href="language.modifier.count.characters.html" accesskey="P">Prev</a></td><td width="50%" align="center" valign="bottom">Chapter 5. Variable Modifiers[变量调节器]</td><td width="25%" align="right" valign="bottom"><a href="language.modifier.count.sentences.html" accesskey="N">Next</a></td></tr></table> # count_paragraphs[计算段数] This is used to count the number of paragraphs in a variable. 计算变量里的段落数量。 | Parameter Position | Type | Required | Default | Description | |-----|-----|-----|-----|-----| | 1 | boolean | No | *FALSE* | This determines whether or not to include whitespace characters in the count. |   | 参数位置 | 类型 | 是否必须 | 默认 | 描述 | |-----|-----|-----|-----|-----| | 1 | boolean | No | *false* | 确定是否计空格算进去。 | <table width="100%" border="0" cellpadding="0" cellspacing="0" class="EXAMPLE"><tr><td> <div class="EXAMPLE"> <a name="AEN364"> </a><strong>Example 5.5. count_paragraphs </strong> <table border="0" bgcolor="#E0E0E0" width="100%"><tr><td> <p>&lt;?php<br/> $smarty-&gt;assign('articleTitle',<br/> "War Dims Hope for Peace. Child's Death Ruins Couple's Holiday.\n<br/> Man is Fatally Slain. Death Causes Loneliness, Feeling of Isolation."<br/> );<br/> ?&gt;<br/><br/> Where template is:</p> <p>{$articleTitle}<br/> {$articleTitle|count_paragraphs}<br/><br/> Will output:<br/> War Dims Hope for Peace. Child's Death Ruins Couple's Holiday.<br/> Man is Fatally Slain. Death Causes Loneliness, Feeling of Isolation.<br/> 2 </p></td></tr></table><p>See also count_words, count_sentences and count_words.<br/> 参见<a href="language.modifier.count.words.html">count_words</a>、<a href="language.modifier.count.sentences.html">count_sentences</a>和<a href="language.modifier.count.words.html">count_words</a>。</p></div></td></tr></table> <table summary="Footer navigation table" width="100%" border="0" cellpadding="0" cellspacing="0"><tr><td width="33%" align="left" valign="top"><a href="language.modifier.count.characters.html" accesskey="P">Prev</a></td><td width="34%" align="center" valign="top"><a href="index.html" accesskey="H">Home</a></td><td width="33%" align="right" valign="top"><a href="language.modifier.count.sentences.html" accesskey="N">Next</a></td></tr><tr><td width="33%" align="left" valign="top">count_characters<br/> 字符计数</td><td width="34%" align="center" valign="top"><a href="language.modifiers.html" accesskey="U">Up</a></td><td width="33%" align="right" valign="top">count_sentences<br/> 计算句数</td></tr></table>