{else:}

{else:} -- adds an PHP else in an if block

概要

Usage ({else:})

説明

adds an else statement in PHP so that blocks of conditional HTML are shown correctly.

例 40-1Setting variables for if

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

例 40-2Else in template

{if:showStuff}Hello{else:}World{end:}

例 40-3Compiled template

<?php if ($t->showStuff)  { ?>Hello<?php } else { ?>World<<?php } ?>

例 40-4The output

World