/**
* Character filtering
* $ Santype 1: Remove HTML, XML, and PHP tags,
* 2: Remove HTML, XML, and PHP tags, convert characters into HTML entities, encode double quotation marks and single quotation marks
* 3: Remove tags in HTML, XML, and PHP. Add a backslash (') double quotation mark (") backslash (\) NULL before a specified predefined character.
* 4: Used to clear data retrieved from a database or HTML form (remove HTML, XML, and PHP tags)
* 6: Add a backslash (') double quotation mark (") backslash (\) NULL before the specified predefined character
*
**/
Function sanitize ($ var, $ santype = 1, $ allowable_tags = ''){
If ($ santype = 1) {return strip_tags ($ var, $ allowable_tags = '');}
Elseif ($ santype = 2) {return htmlentities (strip_tags ($ var, $ allowable_tags), ENT_QUOTES, 'utf-8 ');}
Elseif ($ santype = 3 ){
Return addslashes (strip_tags ($ var, $ allowable_tags ));
}
Elseif ($ santype = 4 ){
Return stripslashes (preg_replace ('/<([^>] +)>/els', "' <'. sanitize ('\ 1', 5 ). '>' ", strip_tags ($ var, $ allowable_tags )));
}
Elseif ($ santype = 5 ){
Return preg_replace ('/\ son \ w + \ s * =/is', '', $ var );
}
Elseif ($ santype = 6 ){
Return addslashes ($ var );
}
}
From adamboy