美文网首页
php strip_tags函数怎么用

php strip_tags函数怎么用

作者: zhangH_ed64 | 来源:发表于2019-05-28 15:17 被阅读0次

php strip_tags函数用于剥去字符串中的HTML标签,其语法是strip_tags(string,allow),参数string是必须,规定要检查的字符串,allow是可选,规定允许的标签。

php strip_tags函数怎么用?

作用:剥去字符串中的 HTML 标签

语法:

1strip_tags(string,allow)

参数:

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

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

说明:strip_tags() 函数剥去字符串中的 HTML、XML 以及 PHP 的标签。该函数始终会剥离 HTML 注释。这点无法通过 allow 参数改变。该函数是二进制安全的。

php strip_tags()函数使用示例1:

<?php

echostrip_tags("<p>Hello <b>world!</b></p>","<b>");

?>

输出:

Hello world

php strip_tags()函数使用示例2:

<?php

$i= "<b>hello<i> php.cn</i></b>";

$j= strip_tags($i,'<i>');

echo$j;

?>

输出:

hello <i>php.cn</i>

以上就是php strip_tags函数怎么用的详细内容

相关文章

网友评论

      本文标题:php strip_tags函数怎么用

      本文链接:https://www.haomeiwen.com/subject/blddtctx.html