我需要你的帮助相关的 php。在 php 中,我只想允许 html<img>
标签,我尝试了 php 的内置函数strip_tags()
,但它没有给我我需要的输出。例如,在下面的代码中strip_tags()
允许 img 标签,但与文本一起。
$img = "<img src='/img/fawaz.jpg' alt= ''> <br /> <p> This is a detailed paragraph about Fawaz and his mates.</p>";
echo strip_tags($img , "<img>");
仅允许<img>
或仅来自函数或变量的任何标记的正确方法是什么。任何帮助将不胜感激。
谢谢