How can I check if a variable exists in Smarty?

Dail picture Dail · Oct 13, 2011 · Viewed 36.4k times · Source

I'm using Smarty template engine.

I'm doing a simple login page. I set a variabile named error with a message if there are some problems, but IF NOT I get:

Notice: Undefined index: error

How could I check if this variable exists?

I only do:

{if $error}<h1>{$error}</h1>{/if}

thanks

Answer

Wesley van Opdorp picture Wesley van Opdorp · Oct 13, 2011

There you go!

{if isset($error)}