Variable Modifiers

PHP Smarty

Smarty - the compiling PHP template engine
Prev 来源:PHP中文社区 Next

Chapter 5. Variable Modifiers [变量调节器]

{* Uppercase the title *}

<h2>{$title|upper}</h2>

{* Truncate the topic to 40 characters use ... at the end *}
Topic: {$topic|truncate:40:"..."}

{* format a literal string *}
{"now"|date_format:"%Y/%m/%d"}

{* apply modifier to a custom function *}
{mailto|upper address="[email protected]"}

capitalize

index.php:

$smarty = new Smarty;
$smarty->assign('articleTitle', 'Police begin campaign to rundown jaywalkers.');
$smarty->display('index.tpl');

index.tpl:

{$articleTitle}
{$articleTitle|capitalize}

OUTPUT:

Police begin campaign to rundown jaywalkers.
Police Begin Campaign To Rundown Jaywalkers.

Prev 来源:PHP中文社区 Home Next
{$smarty.template} Up [计算字符数] count_characters