Question about handling undefined variables

From: Date: Fri, 11 Jan 2002 00:06:10 +0000
Subject: Question about handling undefined variables
Groups: php.smarty.general 
Request: Send a blank email to php-smarty-general+get-2515@lists.php.net to get a copy of this message
Hello, I am using Smarty for a system that I am building and am really impressed with what I have been able to do so far. But I have a question about how to handle undefined variables. What I have is a template that resembles a form that I am filling out. Because not all of the items may have answers, the PHP code before Smarty may or may not have defined/assigned all of the variables that are on the template. Therefore, when displaying the processed template, I receive error messages like "Warning: Undefined index: description in ... on line ..." My assumption would have been that Smarty would have handled this and output nothing if a variable was not assigned (maybe with an error in the popup debug console). But it doesn't, so I have tried the following 1) {if $description neq ""} {$description} {/if} 2) {$description | default: ""} 3) {assign var="description" value=$description | default: ""} {$description} None of these work. They all produce the same error. Can somebody provide some advice on how to handle this situation? My guess is something simple that I am missing. Thanks. _________________________________________________________ Do You Yahoo!? Get your free @yahoo.com address at http://mail.yahoo.com

« previous php.smarty.general (#2515) next »