function s_addslashes($string, $force = 0) { if(!get_magic_quotes_gpc()) { if(is_array($string)) { foreach($string as $key => $val) { $string[$key] = s_addslashes($val, $force); } } else { $string=str_replace("","& # x",$string); // //过滤一些不安全字符 $string = addslashes($string); } } return $string; } //用法实例: $_COOKIE = c_addslashes($_COOKIE); $_POST = c_addslashes($_POST); $_GET = c_addslashes($_GET); //在公共文件中加入 if($_FILES){ foreach( $_FILES as $key => $_value ) { $_FILES[$key]['type'] =$_value['type']; } if(substr($_FILES[$key]['type'],0,6) !='image/') { exit; } }
希望本文所述对大家的PHP程序设计有所帮助。