您的位置:首页 > 编程语言 > PHP开发

smarty 调用php内置函数

2015-04-23 13:01 246 查看
错误提示::syntax error: (secure mode) 'strstr' not allowed in if statement

smarty 默认if 判断里面只让用几个内置方法,除此之外的不让使用,所以添加上就可以了,

但是你更改完后,需要更新smarty的缓存才会生效

Smarty.class.php  文件的230行

var $security_settings  = array(

                                    'PHP_HANDLING'    => false,

                                    'IF_FUNCS'        => array('array', 'list',

                                                               'isset', 'empty',

                                                               'count', 'sizeof',

                                                               'in_array', 'is_array',

                                                               'true', 'false', 'null','strstr'),  

                                    //  此处添加你需要的php内置方法,smarty 是靠此处来判断是否让该方法可用

                                    'INCLUDE_ANY'     => false,

                                    'PHP_TAGS'        => false,

                                    'MODIFIER_FUNCS'  => array('count'),

                                    'ALLOW_CONSTANTS'  => false,

                                    'ALLOW_SUPER_GLOBALS' => true

                                   );

模板里面这么写

<{if !strstr($data.pic,'http')}>逻辑,逻辑<{/if}>​   

我这是判断是否是远程图片
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  smarty