PHP strip_tags() 函数

PHP 教程 · 2019-01-30 07:56:23

实例

剥去字符串中的 HTML 标签:

<?php
echo strip_tags("Hello <b>world!</b>");
?>

定义和用法

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

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

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

语法

strip_tags(string,allow)


参数 描述
string 必需。规定要检查的字符串。
allow 可选。规定允许的标签。这些标签不会被删除。

技术细节

返回值: 返回被剥离的字符串。
PHP 版本: 4+
更新日志: 自 PHP 5.0 起,该函数是二进制安全的。
自 PHP 4.3 起,该函数始终会剥离 HTML 注释。

更多实例

实例 1

剥去字符串中的 HTML 标签,但允许使用 <b> 标签:

<?php
echo strip_tags("Hello <b><i>world!</i></b>","<b>");
?>

点击查看所有 PHP 教程 文章: https://www.codercto.com/courses/l/5.html

查看所有标签

Algorithms on Strings, Trees and Sequences

Algorithms on Strings, Trees and Sequences

Dan Gusfield / Cambridge University Press / 1997-5-28 / USD 99.99

String algorithms are a traditional area of study in computer science. In recent years their importance has grown dramatically with the huge increase of electronically stored text and of molecular seq......一起来看看 《Algorithms on Strings, Trees and Sequences》 这本书的介绍吧!

Base64 编码/解码
Base64 编码/解码

Base64 编码/解码

XML 在线格式化
XML 在线格式化

在线 XML 格式化压缩工具

正则表达式在线测试
正则表达式在线测试

正则表达式在线测试