Home >Backend Development >PHP Tutorial >:请问如何用正则验证 or 1 = 1

:请问如何用正则验证 or 1 = 1

WBOY
WBOYOriginal
2016-06-23 13:52:101410browse

目的为了防止mysql注入操作。


回复讨论(解决方案)

[\s\S]*?or[\s\S]*?\d+[\s\S]*?=[\s\S]*?\d+

过滤空格和特殊字符

$a = array(  "or 1 = 1",  "Or 1 = 1",  "or 3 =3",  "or now() = now()",  "or 'a' = 'a'",);foreach($a as $s)  echo $s, " :\t\t", preg_match('/or\b.+(\b\w+\b)[^=]*=.*\1/i', $s), PHP_EOL;
or 1 = 1 :		1Or 1 = 1 :		1or 3 =3 :		 1or now() = now() :	1or 'a' = 'a' :		1
还有什么怪异的写法,你加进去自己试

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