【发布时间】:2014-03-17 02:05:48
【问题描述】:
所以我想结合htmlspecialchars和strip_tags的功能。
我目前拥有的元素是:
<form>
....
<section contenteditable="true" placeholder="Please enter your text content here..." class="content" id="content" name="content" type="text" cols="30" rows="10"></section>
....
</form>
然后提交
....
$content = $_POST['content'];
...一些 SQL...
$content = $c['content'];
$new = htmlspecialchars($content, ENT_QUOTES);
我想将 htmlspecialchars 和 strip_tags 组合在一起,它们分别工作并产生正确的结果。
$new = strip_tags($content, '<code><b><i>');
....
所以和例子是这个标签:
<section>
将显示为纯文本,其中此标记:
<code>
格式正确。
【问题讨论】:
-
你试过了吗,$content = str_ireplace([""], ["<",">"], $content);
-
所以我想通了,通过浏览stackoverflow一些发现this
-
和我告诉你的差不多:P <和>大声笑...好吧,朋友祝你好运!
标签: php htmlspecialchars strip-tags