错误提示::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}>
我这是判断是否是远程图片