/** * 过滤转换入脚本 * @param $data * @param $no_replace_key 不需要过滤转换的数据键 * @param string $request_type 请求类型 get post */ function search_content_filter($data = array(), $request_type = ‘get‘, $no_replace_key = array()) { switch (strtolower($request_type)) { case ‘get‘: foreach ($data as $key=>$val) { if(in_array($key, $no_replace_key)) { continue; } $_GET[$key] = trim(htmlspecialchars($val,ENT_QUOTES)); } break; case ‘post‘: foreach ($data as $key=>$val) { if(in_array($key, $no_replace_key)) { continue; } $_POST[$key] = trim(htmlspecialchars($val,ENT_QUOTES)); } break; } } //Utf 8 字符中文截取方法 //截取utf8字符串 function utf8Substr($str, $from, $len) { return preg_replace(‘#^(?:[\x00-\x7F]|[\xC0-\xFF][\x80-\xBF]+){0,‘.$from.‘}‘. ‘((?:[\x00-\x7F]|[\xC0-\xFF][\x80-\xBF]+){0,‘.$len.‘}).*#s‘, ‘$1‘,$str); }
时间: 2024-10-10 02:29:09