Home >Backend Development >PHP Tutorial >php filter all html tags_PHP tutorial

php filter all html tags_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 17:09:371005browse

First we recommend filter_sanitize_string, filter_sanitize_string filter to remove or encode unnecessary characters.

This filter removes data that is potentially harmful to the application. It is used to strip tags and remove or encode unwanted characters.

name: "string"
id-number: 513
Possible options or flags:

filter_flag_no_encode_quotes - This flag does not encode quotes
filter_flag_strip_low - remove characters with ascii value below 32
filter_flag_strip_high - remove characters with ascii value above 32
filter_flag_encode_low - encode characters with ascii value below 32
filter_flag_encode_high - encode characters with ascii value above 32
filter_flag_encode_amp - Encode & character as &

*/

$var="bill gates";

var_dump(filter_var($var, filter_sanitize_string));

/*
The second function strip_tags
The strip_tags() function strips html, xml and php tutorial tags.

Grammar
strip_tags(string,allow)
*/

echo strip_tags("hello world!");

//hello world!

function uh($str)
{
$farr = array(
"/s+/",                                                                                           //Filter out excess whitespace
"/<(/?)(script|i?frame|style|html|body|title|link|meta|?|%)([^>]*?)>/isu",
//Filter