cai555 发表于 2013-2-7 19:41:06

php过滤HTML代码

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>
页: [1]
查看完整版本: php过滤HTML代码