Home >Backend Development >PHP Tutorial >PHP anti-sql injection filtering code_PHP tutorial
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;
}