default

PHP Smarty

Smarty - the compiling PHP template engine
Prev 来源:PHP中文社区 Chapter 5. Variable Modifiers Next

default[默认值]

Parameter Position Type Required Default Description
1 string No empty This is the default value to output if the variable is empty.
这是变量为空的时候的默认输出。
index.php:

$smarty = new Smarty;
$smarty->assign('articleTitle', 'Dealers Will Hear Car Talk at Noon.');
$smarty->display('index.tpl');

index.tpl:

{$articleTitle|default:"no title"}
{$myTitle|default:"no title"}

OUTPUT:

Dealers Will Hear Car Talk at Noon.
no title

Prev 来源:PHP中文社区 Home Next
date_format Up escape