1.函数的构建function inject_check($sql_str) {return eregi('select|insert|update|delete|\'|\/\*|\*|\.\.\/|\.\/|union|into|load_file|outfile', $sql_str); // 进行过滤}function verify_id($id=null) {if (!$id) { exit('没有提交参数!'); } // 是否为氏瞎空判断elseif (inject_check($id)) { exit('提交的参数非法!'); } // 注射判断elseif (!is_numeric($id)) { exit('提交的参数非法!'); } // 数字判断$id = intval($id); // 整型化return $id;}?function str_check( $str ) {if (!get_magic_quotes_gpc()) { // 判断magic_quotes_gpc是否打开$str = addslashes($str); // 进行过滤}$str = str_replace("_", "\_", $str); // 把 '_'过滤掉$str = str_replace("%", "\%", $str); // 把 '%'过滤掉return $str;}function post_check($post) {if (!get_magic_quotes_gpc()) { // 判断magic_quotes_gpc是否为打开$post = addslashes($post); // 进槐哗行magic_quotes_gpc没有打开的情况对提交数据的过滤}$post = str_replace("_", "\_", $post); // 把 '_'过滤掉$post = str_replace("歼明空%", "\%", $post); // 把 '%'过滤掉$post = nl2br($post); // 回车转换$post = htmlspecialchars($post); // html标记转换return $post;}2.函数的使用实例<?phpif (inject_check($_GET['id'])){exit('你提交的数据非法,请检查后重新提交!');}else{$id = $_GET['id'];//处理数据………………}?>