六狼论坛

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博账号登陆

只需一步,快速开始

搜索
查看: 165|回复: 0

php过滤HTML代码

[复制链接]

升级  55.67%

111

主题

111

主题

111

主题

举人

Rank: 3Rank: 3

积分
367
 楼主| 发表于 2013-2-7 19:41:06 | 显示全部楼层 |阅读模式
strip_tags --- 去除字串中的HTML和PHP标签

语法 : string strip_tags (string str [, string allowable_tags])

说明 :

此函式试着从给予的字串中去除所有HTML和PHP标签,如果是不完整或是假的标签时则会有错误,它和fgetss( )使用相同的方法去除标签。

你可以使用第三个参数来指定不去除那些标签


注意 : allowable_tags增加在PHP 3.0.13,PHP 4B3中
 
Example #1 strip_tags() example
 
 
<?php$text = '<p>Test paragraph.</p><!-- Comment --> <a href="#fragment">Other text</a>';echo strip_tags($text);echo "\n";// Allow <p> and <a>echo strip_tags($text, '<p><a>');?> 
The above example will output:

Test paragraph. Other text
<p>Test paragraph.</p> <a href="#fragment">Other text</a>
您需要登录后才可以回帖 登录 | 立即注册 新浪微博账号登陆

本版积分规则

快速回复 返回顶部 返回列表