Php character filtering method. * ** Character filtering ** $ santype1: removes HTML, XML, and PHP tags. * 2: removes HTML, XML, and PHP tags and converts characters to HTML entities, double quotation marks and single quotation marks ** 3 /**
* 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
Escape * character filtering * $ santype 1: removes HTML, XML, and PHP tags. * 2: removes HTML, XML, and PHP tags, and converts characters to HTML entities, encode double quotation marks and single quotation marks * 3...