Sponsored Link

ifdef / elsedef

ifdef/elsedef tag does the processing in accordance with whether a PHP variable is defined.

Syntax

{{ @ifdef val_name }}
    statements
{{ @elsedef }}
    statements
{{ @endifdef }}

PHP

$assign['sample_ifdef1'] = 'foo';
$assign['sample_ifdef2'] = 'bar';
unset($assign['sample_ifdef2']);

Template

{{ @ifdef sample_ifdef1 }}
    defined : {{ sample_ifdef1 }}
{{ @elsedef }}
    undefined
{{ @endifdef }}
<br>
{{ @ifdef sample_ifdef2 }}
    defined : {{ sample_ifdef2 }}
{{ @elsedef }}
    undefined
{{ @endifdef }}

Result

defined : foo
undefined