Home  >  Article  >  Backend Development  >  php对url保险过滤处理

php对url保险过滤处理

WBOY
WBOYOriginal
2016-06-13 13:10:50770browse

php对url安全过滤处理

preg_match_all( '/([0-9])=([\%\+\-\.\/0-9\=A-Z\_]+)/i', $_SERVER['QUERY_STRING'], $_GET );
$_GET = ( $_GET[0] ? array_combine( $_GET[1], $_GET[2] ) : array() ) + array_fill( 0, 10, '' );


现在你的 $_GET 只接受 0-9 的设置当然这些URL是很安全的

?0=123&1=456非法URL&2=789" AND xxx=1&3=0ABC&4=BASE64_CODE&5=URLENCODE

看看

可以接受的 URL [\%\+\-\.\/0-9\=A-Z\_]+

能理解把,并且已经对不存在的 设置 设置为 空防止出错

通常 isset( $_GET[0] ) 可以变为 $_GET[0] 没有警告信息了

已经把 $_GET   0-9   不存在的设置好了

啊 有人说  直接 变量不会有警告信息?? 我。。

解释  没有警告信息不代表没有生成警告信息

在前面把 错误汇报级别设置最高

error_reporting(8191);

你看看有吗 而且我对PHP错误信息做过结实和速度测试

请看 php解释为什么要用isset()

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