Home  >  Article  >  Backend Development  >  PHP anti-sql injection filtering code_PHP tutorial

PHP anti-sql injection filtering code_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 17:09:44789browse

We provide three functions to filter out some special characters. They mainly use PHP to filter out SQL sensitive strings. Let’s take a look at this code. Friends in need take it and take a look.

We provide three functions to filter out some special characters. We mainly use the PHP tutorial to filter out SQL sensitive strings. Let’s take a look at this code. Friends in need take it and take a look.

function phps tutorial ql_show($str){
$str = stripslashes($str);
$str = str_replace("\", "", $str);
$str = str_replace("/", "/", $str);
$str = str_replace(" ", " ", $str);
$str = str_replace(",", ",", $str);
return $str;
}
function phpsql_post($str){
$str = stripslashes($str);
$str = str_replace("|", "|", $str);
$str = str_replace("<", "<", $str);
$str = str_replace(">", ">", $str);
$str = str_replace(" ", " ", $str);
$str = str_replace(" ", " ", $str);
$str = str_replace("(", "(", $str);
$str = str_replace(")", ")", $str);
$str = str_replace("`", "`", $str);
//$str = str_replace("'", "'", $str);
$str = str_replace('"', """, $str);
$str = str_replace(",", ",", $str);
$str = str_replace("$", "$", $str);
$str = str_replace("", "\", $str);
$str = str_replace("/", "/", $str);
return $str;
}
function phpsql_replace($str){
$str = stripslashes($str);
$str = str_replace("'", "'", $str);
return $str;
}

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/629732.htmlTechArticleWe provide three functions to filter some special characters, mainly using php to filter sql sensitive strings It's been filtered out, okay let's take a look at this code. Take it to friends in need...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn