Hi everybody,
I am writing a function to handle user data before it is imported into the database, exported to the screen and when downloaded (with the file name).
However, I do not know how to arrange it to work properly, I will post the code below, please help me rearrange it.
function SafelyData($string) {
$string= trim($string);
$string= addslashes($string);
$string = stripslashes($string);
$string= strip_tags($string);
$string= htmlentities($string);
$string= htmlspecialchars($string, ENT_QUOTES);
if(is_array($string)) {
$string= array_map(__METHOD__, $string);
}
if(is_string($string)) {
$string= str_replace(array('\\', "\0", "\n", "\r", "'", '"', "\x1a"), array('\\\\', '\\0', '\\n', '\\r', "\\'", '\\"', '\\Z'), $string);
}
return $string;
}
Please temporarily ignore mysqli_real_escape_string, mysqli_prepare and PDO.
Thank you very much.