default — This is used to set a default value for a variable. If the variable is unset or an empty string, the given default value is printed instead. Default takes the one argument.
With error_reporting(E_ALL)
, undeclared variables will always throw an error within the template. This function is useful for replacing null or zero length strings.
<?php
$Tplix->assign('name', "Dealers Will Hear Car Talk at Noon.");
$Tplix->assign('email',"");
?>
Where template is: Syntax
{$name|default:'no title'}
{$myTitle|default:'no title'}
{$email|default:'No email address available'}
{default $var1 "bar"}
The above example will output:
Dealers Will Hear Car Talk at Noon.
no title
No email address available
bar