开发者

strip_tags not working properly

I am using this in my tpl file , like

{strip_tags({$obj->getfunc()})}

and it gives mes error like syntax error: unrecognized tag:

is anything wrong with th开发者_如何学Pythone syntax ??

full error message

<b>Fatal error</b>:  Smarty error: [in file.tpl line 7]: syntax error: unrecognized tag: strip_tags({$obj->getfunc() 


Your code:

strip_tags({$obj->getfunc()})

The problem here is the {} curly braces. I don't know why you thought you needed these, but they're not required.

[edit]

I see you've edited the question/comments to note that you're using Smarty. Now the curly braces make sense.

I guess you started off with just {$obj->getfunc()}, and decided to do strip_tags() on it to prevent hacks.

The {} braces are part of Smarty, so you should only use them this way for the entire block of code. So you need them outside of the `strip_tags() function, and not inside, on the method call as you had it previously.

So instead of this strip_tags({$obj->getfunc()}), you should have something like this:

{strip_tags($obj->getfunc())}

Hope that helps.

[edit 2]

Okay, I'm a PHP dev, not a smarty dev. The code above is valid PHP (not counting the {} braces). But maybe smarty doesn't like that.

I googled and found this page on the Smarty website: http://www.smarty.net/docs/en/language.modifier.strip.tags.tpl

That page gives some specific Smarty syntax for strip_tags, so based on that, it looks like you code should look like this:

{$obj->getfunc()|strip_tags}


I'd run this function not at presentation level but at business logic level.


Replace { from JavaScript code in your template with {literal} and } with {/literal}

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜