010_basic_if.php

open standalone ↗
PHP Source
<?php

///////////////////////////////////////////////////////////////////////////////
// Conditional syntax is available in the form of if/else.                   //
//                                                                           //
// Note: When an if statement references a variable that is *not assigned it //
// will be treated as if it were false.                                      //
///////////////////////////////////////////////////////////////////////////////

include("../sluz.class.php");
$s = new sluz();

$s->assign("weekday", date("D"));
$s->assign("kitten_count", 7);
$s->assign("verbose", true);

print $s->fetch("tpls/010_basic_if.stpl");
TPL Template
{if $weekday === "Wed"}
<h1>It is Wednesday</h1>
{else}
<h1>It is not Wednesday</h1>
{/if}

{if $kitten_count > 4}<p>You have a lot of kittens</p>{/if}

{if !$quiet}<div>Here is some detailed information</div>{/if}

{if $verbose && !$quiet}Since we are not quiet, here is even more information{/if}
OUT Live output iframe preview