首页 > 代码库 > php参数过滤
php参数过滤
//参数过滤
$sVariablesOrder = ini_get( ‘variables_order‘ );
$request = array();
//过滤不安全数据
for ( $i = 0; $i < strlen( $sVariablesOrder ); $i++ ){
$cVariableFlat = strtolower( $sVariablesOrder[$i] );
switch ( $cVariableFlat ){
case ‘e‘:
$filtered = filter_input_array ( INPUT_ENV, FILTER_SANITIZE_SPECIAL_CHARS );
break;
case ‘g‘:
$filtered = filter_input_array ( INPUT_GET, FILTER_SANITIZE_SPECIAL_CHARS );
break;
case ‘p‘:
$filtered = filter_input_array ( INPUT_POST, FILTER_SANITIZE_SPECIAL_CHARS );
break;
case ‘c‘:
$filtered = filter_input_array ( INPUT_COOKIE, FILTER_SANITIZE_SPECIAL_CHARS );
break;
case ‘s‘:
$filtered = filter_input_array ( INPUT_SERVER, FILTER_SANITIZE_SPECIAL_CHARS );
break;
}
if ( !empty( $filtered ) ){
$request = array_merge( $request, $filtered );
}
}
本文出自 “Smile” 博客,转载请与作者联系!