Re:Question about handling undefined variables
| From: | Andrei Zmievski | Date: | Mon, 14 Jan 2002 15:00:37 +0000 |
| Subject: | Re:Question about handling undefined variables | ||
| References: | 1 2 | Groups: | php.smarty.general |
| Request: | Send a blank email to php-smarty-general+get-2535@lists.php.net to get a copy of this message | ||
On Mon, 14 Jan 2002, Andrei Zmievski wrote:
> Try this patch against the current snapshot:
>
> --- Smarty_Compiler.class.php 2001/12/28 16:53:33 1.92
> +++ Smarty_Compiler.class.php 2002/01/14 14:18:10
> @@ -213,5 +213,5 @@
> settype($tag_command, 'array');
> $this->_parse_vars_props($tag_command);
> - return "<?php echo $tag_command[0]; ?>\n";
> + return "<?php if (isset($tag_command[0])) echo $tag_command[0];
> ?>\n";
> }
>
> Be warned that this will slow-down the variable output by some
> percentage. Feel free to determine what that percentage is and let us
> know too. :)
Hmm, no, forget it. This will work only for variables without modifiers
and all that.
The only other one I could come up with is this:
--- Smarty_Compiler.class.php 2001/12/28 16:53:33 1.92
+++ Smarty_Compiler.class.php 2002/01/14 14:59:54
@@ -1018,4 +1018,6 @@
}
+ $output = "(isset($output) ? $output : '')";
+
$this->_parse_modifiers($output, $modifiers);
Although that assumes that if the variable is not set, then it's empty
string.
-Andrei
Nobody tried to design Windows - it just grew in random
directions without any kind of thought behind it.