Re: Handling undefined variables

From: Date: Tue, 12 Mar 2002 19:56:07 +0000
Subject: Re: Handling undefined variables
References: 1  Groups: php.smarty.general 
Request: Send a blank email to php-smarty-general+get-3020@lists.php.net to get a copy of this message
Well, let me correct myself... This code doesn't work too well -- I'll have to play with it a bit more. On Tue, Mar 12, 2002 at 11:32:32AM -0800, Ben Curtis wrote: > I read with interest the thread on this subject that happened in January > (http://marc.theaimsgroup.com/?t=101072708400001&r=1&w=2), but I noticed > the problem is still there in the latest version of smarty. May I > suggest the following patch? > > --- Smarty_Compiler.class.php Thu Feb 21 09:14:10 2002 > +++ Smarty_Compiler.class.php Tue Mar 12 11:17:18 2002 > @@ -1064,7 +1064,7 @@ > $output = "\$this->_smarty_vars['$var_name']"; > } > } else { > - $output = "\$this->_tpl_vars['$var_name']"; > + $output = isset($GLOBALS[$var_name]) ? > "\$this->_tpl_vars['$var_name']" : "''"; > } > > foreach ($indexes as $index) { > > > This isn't perfect... you could still have a variable existing that > doesn't get assigned to the template vars and still generate a warning, > but it would cut down the warnings quite a bit. Plus, it allows you to > still use a mod_handler such as providing a default. Of course, I don't > know much this would slow things down, but I thought I'd make the > suggestion anyway. Thoughts? >

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