PHP Tutorial converts HTML tags into legitimate HTML code programs
function Ihtmlspecialchars ($string)
{
if (Is_array ($string))
{
foreach ($string as $key => $val)
{
$string [$key] = Ihtmlspecialchars ($val);
}
Else
{
$string = Preg_replace ('/& (d{3,5}|x[a-fa-f0-9]{4}) |[ a-za-z][a-z0-9]{2,5});)/', ' &1 ',
Str_replace (' & ', ' "', ' < ', ' > '), Array (' & ', ' " ', ' < ', ' > '), $string));
}
return $string;
}//instance
$str = ' <a href= ' www.jzread.com ' >dfdfd</a> ';
echo Ihtmlspecialchars ($STR);
echo ' <br > ';
Echo <a href="www.jzread.com">dfdfd</a> This will prevent some unsafe factors.
echo Htmlspecialchars ($STR);
//print <a href="www.jzread.com">dfdfd</a>
/*
Two results are identical, so personally feel that the functions from PHP are more efficient than the user-defined function
*/