转义:将字符转换为 HTML 转义字符
<?php
$str = "This is some <b>bold</b> text.";
echo htmlspecialchars($str);
?>
更多功能选项可使用 htmlentities 函数
运行结果:实体字符
This is some <b>bold</b> text.
解码:将 HTML 实体转换为其对应的字符
<?php
$str = "This is some <b>bold</b> text.";
echo htmlspecialchars_decode($str);
?>
更多功能选项可使用 html_entity_decode 函数
运行结果:特殊字符
This is some <b>bold</b> text.
0 条评论