PHP htmlentity允许< b>和< i>只要 [英] PHP htmlentities allow <b> and <i> only

查看:61
本文介绍了PHP htmlentity允许< b>和< i>只要的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用htmlentities()有没有办法我可以设置为仅允许<b><i>转换为粗体和斜体文本?我知道有一种方法可以做到这一点,但是我已经忘记了.

Using htmlentities() is there a way I can set to allow only <b> and <i> to convert into bold and italic text? I know there was one way of doing this, but i have forgotten.

推荐答案

非常简单

<?php
$string = htmlentities($text);
$string = str_replace(array("&lt;i&gt;", "&lt;b&gt;", "&lt;/i&gt;", "&lt;/b&gt;"), array("<i>", "<b>", "</i>", "</b>"), $string);

这篇关于PHP htmlentity允许&lt; b&gt;和&lt; i&gt;只要的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆