如何编写PHP防止SQL注入的函数?
- 内容介绍
- 文章标签
- 相关推荐
本文共计95个文字,预计阅读时间需要1分钟。
PHP 防SQL注入函数示例:
phpfunction inject_check($Sql_Str) { // 自动过滤SQL的注入语句。 $check=preg_match('/select|insert|update|delete|\'|\\\$|union|into|load_file|outfile/i', $Sql_Str); if ($check) { return false; } return true;}
1.[代码][PHP]代码
function inject_check($Sql_Str) {//自动过滤Sql的注入语句。 $check=preg_match('/select|insert|update|delete|\'|\\*|\*|\.\.\/|\.\/|union|into|load_file|outfile/i',$Sql_Str); if ($check) { echo '<script language="JavaScript">alert("系统警告:\n\n请不要尝试在参数中包含非法字符尝试注入!");</script>'; exit(); }else{ return $Sql_Str; } }
本文共计95个文字,预计阅读时间需要1分钟。
PHP 防SQL注入函数示例:
phpfunction inject_check($Sql_Str) { // 自动过滤SQL的注入语句。 $check=preg_match('/select|insert|update|delete|\'|\\\$|union|into|load_file|outfile/i', $Sql_Str); if ($check) { return false; } return true;}
1.[代码][PHP]代码
function inject_check($Sql_Str) {//自动过滤Sql的注入语句。 $check=preg_match('/select|insert|update|delete|\'|\\*|\*|\.\.\/|\.\/|union|into|load_file|outfile/i',$Sql_Str); if ($check) { echo '<script language="JavaScript">alert("系统警告:\n\n请不要尝试在参数中包含非法字符尝试注入!");</script>'; exit(); }else{ return $Sql_Str; } }

