TPLix

No results for ""

Default

2 min read Jun 2, 2026
--- title: default autoseo: enabled: true theme: learn2 child_type: default admin: children_display_order: collection visible: true ---

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.

Note: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',"");
?>
	
Examples:

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
    

Leave a Comment

Not published. Used to notify you on approval.

Comments are moderated before appearing.