> Smarty模板引擎中文在线手册 > nl2br [换行符替换成
]

nl2br
换行符替换成
<br />


All linebreaks will be converted to <br /> tags in the given variable. This is equivalent to the PHP nl2br() function.

所有的换行符将被替换成 <br />.功能同PHP中的nl2br()函数一样.

Example 5-14. nl2br
例 5-14.换行符替换成<br />

index.php:

$smarty = new Smarty;
$smarty->assign('articleTitle', "Sun or rain expected\ntoday, dark tonight");
$smarty->display('index.tpl');

index.tpl:

{$articleTitle|nl2br}

OUTPUT:

Sun or rain expected<br />today, dark tonight
上一篇:
下一篇: