I’ve been working with the Smarty Template Engine with display_errors = Off. Turning it on, I realize that just leaving:
<li{$page['home']}>...</li>
<li{$page['about']}>...</li>
where,
$page['home'] = ' class="current"';
$this->smarty->assign("page", $page);
gives me an error, saying that $page['about'] is not defined.
As of now, I see my options are to either turn display_errors = Off or to do this:
<li{if isset($page['home'])}{$page['home']}{/if}>...</li>
<li{if isset($page['about'])}{$page['about']}{/if}>...</li>
Any reason why I should use one over the other? Or any better solution? Thanks.
In short, no difference…
BUT, it’s much safer to define your empty variables as
NULL. This protects you from leftovers, or things coming from other pages that you forgot about later, etc… It’s just being safe.A lot of people swear by making unused variables (that COULD be set) to NULL before starting to use them.