位置: 编程技术 - 正文
推荐整理分享PHP字符串函数strip_tags()的用法(php str函数),希望有所帮助,仅作参考,欢迎阅读内容。
文章相关热门搜索词:php中字符串函数,php string函数,php str函数,php字符串型数据的定义方式,php字符串定义,php 字符串函数,php 字符串函数,php string函数,内容如对您有帮助,希望把文章链接给更多的朋友!
(PHP 4, PHP 5)
strip_tags — 从字符串中去除 HTML 和 PHP 标记
说明 string strip_tags ( string $str [, string $allowable_tags ] )该函数尝试返回给定的字符串 str 去除空字符、HTML 和 PHP 标记后的结果。它使用与函数 fgetss() 一样的机制去除标记。
参数str
输入字符串。
allowable_tags使用可选的第二个参数指定不被去除的字符列表。
Note:
HTML 注释和 PHP 标签也会被去除。这里是硬编码处理的,所以无法通过 allowable_tags 参数进行改变。
Note:
This parameter should not contain whitespace. strip_tags() sees a tag as a case-insensitive string between < and the first whitespace or >. It means that strip_tags("<br/>", "<br>") returns an empty string.
返回值返回处理后的字符串。
更新日志版本 说明 5.0.0 strip_tags() 变为二进制安全的。 4.3.0 HTML 注释总是被删除。
范例
Example #1 strip_tags() 范例
<?php$text='<p>Testparagraph.</p><!--Comment--><ahref="#fragment">Othertext</a>';echostrip_tags($text);echo"n";//允许<p>和<a>echostrip_tags($text,'<p><a>');?>以上例程会输出:
注释 Warning由于 strip_tags() 无法实际验证 HTML,不完整或者破损标签将导致更多的数据被删除。
Warning该函数不会修改 allowable_tags 参数中指定的允许标记的任何属性,包括 style 和 onmouseover 属性,用户可能会在提交的内容中恶意滥用这些属性,从而展示给其他用户。
Note:
输入 HTML 标签名字如果大于 字节(bytes)将会被认为是无效的,无论 allowable_tags 参数是怎样的。
参见htmlspecialchars() - Convert special characters to HTML entities
PHP字符串函数strcoll()的用法 strcoll(PHP4=4.0.5,PHP5)strcoll基于区域设置的字符串比较说明intstrcoll(string$str1,string$str2)注意该比较区分大小写。和strcmp()不同,该函数不是二进制安全的。str
PHP字符串函数strcspn()的用法 strcspn(PHP4,PHP5)strcspn获取不匹配遮罩的起始子字符串的长度说明intstrcspn(string$str1,string$str2[,int$start[,int$length]])返回str1中,所有字符都不存在于str2范围的
PHP字符串函数str_replace()的用法 str_replace(PHP4,PHP5)str_replace子字符串替换说明mixedstr_replace(mixed$search,mixed$replace,mixed$subject[,int&$count])该函数返回一个字符串或者数组。该字符串或数组是将
标签: php str函数
本文链接地址:https://www.jiuchutong.com/biancheng/278821.html 转载请保留说明!友情链接: 武汉网站建设