php 去掉html标签的函数
2022-12-02 09:01:16
95
{{single.collect_count}}

php去掉html标签的函数是“strip_tags”,该函数的作用就是剥去字符串中的HTML、XML以及PHP的标签,其使用语法是“strip_tags(string,allow)”。

php入门到就业线上直播课:进入学习
Apipost = Postman + Swagger + Mock + Jmeter 超好用的API调试工具:点击使用

本文操作环境:Windows7系统、PHP7.1、Dell G3电脑。

strip_tags() 函数剥去字符串中的 HTML、XML 以及 PHP 的标签。

注释:该函数始终会剥离 HTML 注释。这点无法通过 allow 参数改变。

注释:该函数是二进制安全的。

语法

strip_tags(string,allow)
登录后复制

参数

string必需。规定要检查的字符串。

allow可选。规定允许的标签。这些标签不会被删除。

实例

剥去字符串中的 HTML 标签:

<?phpecho strip_tags("Hello <b>world!</b>");?>
登录后复制

输出:

Hello world!
登录后复制

【推荐:PHP视频教程

以上就是php 去掉html标签的函数的详细内容,更多请关注php中文网其它相关文章!

回帖
全部回帖({{commentCount}})
{{item.user.nickname}} {{item.user.group_title}} {{item.friend_time}}
{{item.content}}
{{item.comment_content_show ? '取消' : '回复'}} 删除
回帖
{{reply.user.nickname}} {{reply.user.group_title}} {{reply.friend_time}}
{{reply.content}}
{{reply.comment_content_show ? '取消' : '回复'}} 删除
回帖
收起
没有更多啦~
{{commentLoading ? '加载中...' : '查看更多评论'}}