|
Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon. |
|
View previous topic :: View next topic |
Author |
Message |
slemke Smarty n00b
Joined: 01 Jun 2003 Posts: 1
|
Posted: Sun Jun 01, 2003 11:53 am Post subject: use of "isset" in template safe ? |
|
|
Hello @all,
I have just started to use smarty. After figuring out, how to build my templates I have a little question.
The following code inside my template does work for me without any problems:
{if isset($navi_left)}
{include file="$navi_left"}
{/if}
Is the use of "isset" safe ?
When using:
{if $navi_left!=""}
it also works, but my php says:
Notice: Undefined index: navi_left in...
(my php-error-reporting ist ALL)
Regards,
Sebastian |
|
Back to top |
|
boots Administrator
Joined: 16 Apr 2003 Posts: 5611 Location: Toronto, Canada
|
Posted: Wed Jun 25, 2003 5:21 am Post subject: |
|
|
Hi Sebastion. Isset is safe -- at least for the forseeable future. Note that other PHP functions can also be used in your if statements like is_a(), count(), etc.
As for the warning, because you have error reporting set to all, you will indeed get a warning whenever you attempt to access a Smarty var that has not been assigned. This is because Smarty vars are stored in an associative array and at your error level, PHP throws a warning whenever you attempt to access a non-existant key in an assoicative array.
HTH.
Last edited by boots on Wed Jun 25, 2003 7:40 am; edited 1 time in total |
|
Back to top |
|
messju Administrator
Joined: 16 Apr 2003 Posts: 3336 Location: Oldenburg, Germany
|
Posted: Wed Jun 25, 2003 7:16 am Post subject: |
|
|
FYI: when debugging is turned off, smarty lowers the error-reporting itself to supress warnings of undefined template-vars. |
|
Back to top |
|
boots Administrator
Joined: 16 Apr 2003 Posts: 5611 Location: Toronto, Canada
|
Posted: Wed Jun 25, 2003 7:43 am Post subject: |
|
|
@messju: Thanks for that tip! I didn't realize that Smarty did that. I believe it explains the reporting difference in my debug and test environments -- something that was realy bothering me |
|
Back to top |
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|