php HTML转义字符
显示HTML转义字符并还原
$str = htmlentities("<>& *;");
echo $str;
$table = get_html_translation_table(HTML_ENTITIES);
$rev_trans = array_flip($table);
echo strtr($str,$rev_trans);
在HTML表中加入其他转义字符
$str = htmlentities("<>& *;");
echo $str;
$table = get_html_translation_table(HTML_ENTITIES);
$table[" "] = " ";
$encoded = strtr($str, $table);
echo $encoded;
声明:该文观点仅代表作者本人,牛骨文系教育信息发布平台,牛骨文仅提供信息存储空间服务。
- 上一篇: PHP针对HTML实体字符的转义函数
- 下一篇: php提取HTML中字符
