You*_*mon 1 php string escaping
function escape($value){
$magic_quotes_active = get_magic_quotes_gpc();
$new_enough_php = function_exists("mysql_real_escape_string");
if ($new_enough_php) {
if ($magic_quotes_active) {
$value = stripslashes($value);
$value = mysql_real_escape_string($value);
}
elseif (!$magic_quotes_active) {
$value = addslashes($value);
}
return $value;
}
}
Run Code Online (Sandbox Code Playgroud)
很长一段时间我一直在使用上面的函数来转义字符串?现在,我想问一下,我是否需要使用该功能(我发现通过互联网获取适用于大多数PHP版本的字符串)?或者它的制作不必要的复杂?