Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

use of "isset" in template safe ?

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> General
View previous topic :: View next topic  
Author Message
slemke
Smarty n00b


Joined: 01 Jun 2003
Posts: 1

PostPosted: Sun Jun 01, 2003 11:53 am    Post subject: use of "isset" in template safe ? Reply with quote

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
View user's profile Send private message Visit poster's website
boots
Administrator


Joined: 16 Apr 2003
Posts: 5611
Location: Toronto, Canada

PostPosted: Wed Jun 25, 2003 5:21 am    Post subject: Reply with quote

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
View user's profile Send private message
messju
Administrator


Joined: 16 Apr 2003
Posts: 3336
Location: Oldenburg, Germany

PostPosted: Wed Jun 25, 2003 7:16 am    Post subject: Reply with quote

FYI: when debugging is turned off, smarty lowers the error-reporting itself to supress warnings of undefined template-vars.
Back to top
View user's profile Send private message Send e-mail Visit poster's website
boots
Administrator


Joined: 16 Apr 2003
Posts: 5611
Location: Toronto, Canada

PostPosted: Wed Jun 25, 2003 7:43 am    Post subject: Reply with quote

@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 Smile
Back to top
View user's profile Send private message
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> General All times are GMT
Page 1 of 1

 
Jump to:  
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
Protected by Anti-Spam ACP