{if:variable}

{if:variable} -- creates a PHP if statement

概要

Usage ({if:variable}, {if:method()})

説明

creates an if statement, with the argument as a variable or method. You must close an if statement with an {end:} statement, and you may use {else:} with it.

例 40-1Setting variables for if

class example {
    function showDog() {
        return true;
    }

    function output() {
        
        $this->showStuff = true;
        
        .........
        $template->outputObject($this);
    }
}

例 40-2The template

{if:showStuff}Hello{end:}
{if:showDog()}Doggy{end:}

例 40-3Compiled template

<?php if ($t->showStuff)  { ?>Hello<?php } ?>
<?php if ($t->showDog()) {  ?>Doggy<?php } ?>

例 40-4The output

Hello
Doggy