TP3.2自带的I方法使用的是htmlspecialchars过滤,但是默认是不转移单引号的,这就会增加sql注入的风险,因此我们可以按照TP3官方文档,自定义函数,自行过滤
#首先在function文件中添加方法
#\Application\Common\Common\function.php
function htmlentities_custom(str){
return htmlentities(str, ENT_QUOTES);
}
#然后在配置DEFAULT_FILTER中添加该自定义方法
'DEFAULT_FILTER' => 'htmlentities_custom',
#添加完后,清除缓存,即可过滤单引号