default

1.0 1.1 1.2 1.3

Returns a variable or a default value if it’s empty

<?php
default(mixed $value, [ mixed $default = ""])
  • value: the variable to check
  • default: fallback value if the first one is empty

Examples

Example #1

index.tpl
{$var1="foo"}
{$var2=""}
{default $var1 "bar"}
{default $var2 "bar"}
{default $var3 "bar"}

The above example will output:

foo
bar
bar