本文操作环境:windows10系统、php 7.3、thinkpad t480电脑。
在工作中我们可能会需要去除某些html标签,比如i标签、b标签等等。那么我们该如何去除这些html标签呢?
其实想要去除html标签是很简单的,因为php本身已经给我们提供了现有的函数,如strip_tags函数。下面就让我们来介绍下strip_tags函数。
strip_tags() 函数用来剥去字符串中的 html、xml 以及 php 的标签。
语法如下:
strip_tags(string,allow)
参数解释如下:
string 必需。规定要检查的字符串。
allow 可选。规定允许的标签。这些标签不会被删除。
代码示例:
<!doctype html><html><body><?phpecho strip_tags("hello <b>world!</b>");?><p>this function strips a string from html, xml, and php tags. in this example, the <b> tag gets stripped.</p></body></html>
我们一起来看下运行效果:
相关推荐:php视频教程
以上就是php如何去掉i标签的详细内容。
