isset

1.0 1.1 1.2 1.3

Checks whether a variable is not null

<?php
isset(mixed $var)
  • var: variable to check

Examples

Example #1

index.tpl
{if isset($foo)}SET{else}not set or null{/if}
{$foo=1}
{if isset($foo)}SET{else}not set or null{/if}
{$bar=null}
{if isset($bar)}SET{else}not set or null{/if}

The above example will output:

not set or null
SET
not set or null

Note that, doing:

index.tpl
{if $foo}{$foo}{/if}

..is the same as if you used:

index.tpl
{if isset($foo)}{$foo}{/if}