Re: [SMARTY] non-existance variables (one idea)

From: Date: Wed, 16 Oct 2002 03:38:45 +0000
Subject: Re: [SMARTY] non-existance variables (one idea)
References: 1  Groups: php.smarty.general 
Request: Send a blank email to php-smarty-general+get-6172@lists.php.net to get a copy of this message
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On Monday 14 October 2002 08:31, Josh Johnson wrote: > That solution is unideal if case you ever want to upgrade... you'll also > have to check all of the other plugin functions to ensure that it > doesn't create an undesired result. You may want to just extend the > class and redefine that method (_parse_var). You'll still need to take > some time to be sure it doesn't adversely affect the use of other > functions, but you could upgrade without any extra hassle. Well, extending Smarty won't be a problem, but extending Smarty_Copiler will also needs modifications to Smarty as to use the extended class. > Maximum error reporting is only intended for use in development > environments... A have a very detailed error reporting and have a complete error reporting inside an input tag breakes completly the page, making using or developing absolutly imposible. > Honestly, since PHP doesn't require that variables are > declared before use, I think it's excessive to worry about the errors. Well... that's the base of the problem, since PHP doesn't require variables to be declared it doesn't show by default any error when using a non-declared variable, so, if I misstipe or something a variable I'll never know that something is wrong until I see an unexpected beheviour and then, it's hard to spot the bug. > I'd recommend using ini_set("error_reporting", "your desired level") > as > needed, when things aren't working properly, and otherwise keep the > level very low (I can't remember the setting, but it will only echo > fatal errors). Well, that would be an option I'll have to take if nothing can be done in smarty to handle non-declared variables. > Since your relying on smarty to handle variables, and smarty is intended > for display of dynamic webpages, why does it matter? The whole point of > a template system is to keep PHP out of the layout... but you're > willfully exposing unnecessary errors to the user? I don't get you here. I'm not relying on smarty to handle variables, I'm just making smarty show variables {$variable} that's all... variable is not declared, and boom, error. I have a complex error reporting function that during development shows a very long reporting message and when in production, depending on the error, it doesn't show anything or just a short message and store all the errors in a database for later inspection. > Another question that comes to mind is: "why *are* you using variables > that haven't been declared already (it's as simple as > $smarty->assign())?" Well, I like that when an error is generated trying to access/write a database, the form will be filled with the last inserted data... for example, if you're creating an account and the username is already in use, you get the error but the form should be with all the fields filled (people don't like having to refill long forms just because the username was in use), so I print all the variables in the values of the fields of the form, the first time, they're empty and the following times, they're filled with the last thing inserted. If nothing can be done about non-declared variables, I'll have to make two diferent forms or make sure that the variables are declared and emptied the first time (and this will be hard as the script printing the form doesn't know anything about this variables, I'm trying to automatize everything). > I'm curious to see the exact error that you get, and the situation where > you run into it. As I use arrays to handle all of things things I get Undefined index: name, but any error, undefined variable, undefined index, it's the same. > Make sure you're using error reporting for debugging, not to be l33t :) I keep the same error reporting always, when on development, the error reporting function does some thigns (showing any error with long descriptions), on production, just fatal errors are shown and everything is loged to a database for later inspection. Thank you. - -- Pupeno: pupeno@pupeno.com http://www.pupeno.com - --- Help the hungry children of Argentina, please go to (and make it your homepage): http://www.porloschicos.com/servlet/PorLosChicos?comando=donar -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.0.7 (GNU/Linux) iD8DBQE9rN9HLr8z5XzmSDQRAmbcAKDJFyiTWUx200E495+AwsgQZvP1RQCgoBft yF/mZO3IFRBOIhii49ILaEA= =4exI -----END PGP SIGNATURE-----

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