The isset Statement

Testing if a variable is set

About Adam

His name is Adam. His job title is ceo. His salary is $1,000,000. He has 2 kids.

About Alistair

His name is Alistair. His job title is programmer. He has 3 kids. He likes ice cream.


# require the templating library 
require '../source/ViewFish.php'

# first, you instantiate a ViewFish object
$T = new ViewFish\viewfish();

# set the template path

$data = [

# load template
$template    $T->load_template("demo5");

// rendered template
echo $T->render($template,$data); 

$data = [
'likes'=>'ice cream'

// rendered template
echo $T->render($template,$data); 

    <h1>About {{$name|ucfirst}}</h1>
    <p>His name is {{$name|ucfirst}}. His job title is {{$position}}. {{isset $salary}}His salary is {{$salary}}. {{/isset}} {{isset $kids}}He has {{$kids}} kids.{{/isset}} {{isset $likes}}He likes {{$likes}}.{{/isset}} </p>