
PHP如何将HTML字符转义?
在PHP中可以使用“htmlspecialchars()”函数将HTML字符转义,该函数的作用是将特殊字符转换为HTML实体,其用法为“htmlspecialchars($string)”,其参数“$string”代表待转换的字符。
推荐视频教程:《PHP编程从入门到精通(学习路线)》
示例
Test", ENT_QUOTES); echo $new; // zuojiankuohaophpcna href='test'youjiankuohaophpcnTestzuojiankuohaophpcn/ayoujiankuohaophpcn ?>
";
$text = preg_replace($tags, $replacement, $text);
$text = preg_replace("/=\"\"/", "=", $text);
return $text;
}
?>
an example:
this is greater > than this
this is the same = as this
This is a link
Bold italic etc...";
echo fixtags($string);
?>推荐教程:《PHP》
立即学习“PHP免费学习笔记(深入)”;










