作者:小金刚钻 | 来源:互联网 | 2020-09-02 13:38
在PHP中可以使用“htmlspecialchars()”函数将HTML字符转义,该函数的作用是将特殊字符转换为HTML实体,其用法为“htmlspecialchars($string)”,其参数“$string”代表待转换的字符。
Test", ENT_QUOTES);
echo $new; // Test
?>
/i";
$replacement = "<$1$2$3$4$5$6$7$8$9$10>";
$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如何将HTML字符转义?的详细内容,更多请关注 第一PHP社区 其它相关文章!