smarty 调用php内置函数

来源:互联网 发布:北京折叠知乎 编辑:程序博客网 时间:2024/05/02 19:57

错误提示::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}>​   

我这是判断是否是远程图片

0 0
原创粉丝点击