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

default[默认值]

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

This is used to set a default value for a variable. If the variable is empty or unset, the given default value is printed instead. Default takes one argument.
为空变量设置一个默认值。
当变量为空或者未分配的时候,将由给定的默认值替代输出。

Example 5-10. default

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"}

输出结果:

Dealers Will Hear Car Talk at Noon.
no title
这是一份简单的Smarty手册和Smarty教材,熟练掌握Smarty模板,让您做项目事半功倍