Home > Article > Backend Development > PHP introduces two methods of filtering html tags_PHP tutorial
php comes with the function strip_tags
echo strip_tags("hello world! www.ite5e.com");
Custom function:
function filterhtml($str) {
$str=eregi_replace("*[^<>]*>", , $str);
$str=str_replace(" ", , $str);
$str=str_replace("n", , $str);
$str=str_replace("t", , $str);
$str=str_replace("::", :, $str);
$str=str_replace(" ", , $str);
//$str=str_replace(" ", , $str);
return $str;
}
$str = "www.bKjia.c0m";
Call the function echo filterhtml($str);