Home  >  Article  >  Backend Development  >  thinkphp过滤表单表达式的函数,该怎么处理

thinkphp过滤表单表达式的函数,该怎么处理

WBOY
WBOYOriginal
2016-06-13 12:10:40889browse

thinkphp过滤表单表达式的函数
thinkphp有一个函数filter_exp,用于过滤表单中的表达式。
问题是:它过滤什么样的表达式,为什么是$value值等于"or"或"exp"的?
如果不过滤,能否举一个有安全风险的例子?

// 过滤表单中的表达式<br />function filter_exp(&$value){<br />    if (in_array(strtolower($value),array('exp','or'))){<br />        $value .= ' ';<br />    }<br />}

------解决思路----------------------
http://doc.thinkphp.cn/manual/query.html
可查看thinkphp表达式查询,以及具体用法


危害:可以查看php的sql注入章节。
------解决思路----------------------
主要还是为了防止SQL注入的
eg:
UPDATE user SET password='MD5($pwd)'  WHERE id=''  OR username='admin'

建议去看看php有关SQL注入的相关知识

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn