首页 >php教程 >PHP源码 >PHP一个敏感信息过滤思路

PHP一个敏感信息过滤思路

PHP中文网
PHP中文网原创
2016-05-25 17:06:401154浏览

1. [代码][PHP]代码   

//提取中文字符
@header ( 'Content-Type: text/html; charset=utf-8' );
$str = <<<EOT
网站名字:PHP中文网
网站域名:http://www.php.cn/
网站基本情况:
网站快照隔天  网站pr=0  百度权重=2 网站反向链接5853 收录量=53
每天专人维护  定时更新
height="38" border="0" alt="到百度首页"></a>
<p class="tab">
<a href="http://news.baidu.com/ns?cl=2&rn=20&tn=news&word=unicode%D7%D6%B7%FB%D6%B5%20%B7%B6%CE%A7"  onmousedown="return c({&#39;fm&#39;:&#39;tab&#39;,&#39;tab&#39;:&#39;news&#39;})">新闻</a> 
<b>网页</b> <a href="http://tieba.baidu.com/f?kw=unicode%D7%D6%B7%FB%D6%B5%20%B7%B6%CE%A7&fr=wwwt"  onmousedown="return c({&#39;fm&#39;:&#39;tab&#39;,&#39;tab&#39;:&#39;tieba&#39;})">贴吧</a> <a href="http://zhidao.baidu.com/q?ct=17&pn=0&tn=ikaslist&rn=10&word=unicode%D7%D6%B7%FB%D6%B5%20%B7%B6%CE%A7&fr=wwwt"  onmousedown="return c({&#39;fm&#39;:&#39;tab&#39;,&#39;tab&#39;:&#39;zhidao&#39;})">知道</a> <a href="http://mp3.baidu.com/m?tn=baidump3&ct=134217728&lm=-1&word=unicode%D7%D6%B7%FB%D6%B5%20%B7%B6%CE%A7"  onmousedown="return c({&#39;fm&#39;:&#39;tab&#39;,&#39;tab&#39;:&#39;mp3&#39;})">MP3</a> <a href="http://image.baidu.com/i?tn=baiduimage&ct=201326592&lm=-1&cl=2&word=unicode%D7%D6%B7%FB%D6%B5%20%B7%B6%CE%A7"  onmousedown="return c({&#39;fm&#39;:&#39;tab&#39;,&#39;tab&#39;:&#39;pic&#39;})">图片</a> <a href="http://video.baidu.com/v?ct=301989888&rn=20&pn=0&db=0&s=25&word=unicode%D7%D6%B7%FB%D6%B5%20%B7%B6%CE%A7"  onmousedown="return c({&#39;fm&#39;:&#39;tab&#39;,&#39;tab&#39;:&#39;video&#39;})">视频</a> <a href="http://map.baidu.com/m?word=unicode%D7%D6%B7%FB%D6%B5%20%B7%B6%CE%A7&fr=ps01000"  onmousedown="return c({&#39;fm&#39;:&#39;tab&#39;,&#39;tab&#39;:&#39;map&#39;})">地图</a> <span id="tb_mr" onmousedown="return c({&#39;fm&#39;:&#39;tab&#39;,&#39;tab&#39;:&#39;tbmore&#39;});"><b>更多</b><small>▼</small></span></p><p id="more"><a href="http://baike.baidu.com/searchword/?word=unicode%D7%D6%B7%FB%D6%B5%20%B7%B6%CE%A7&pic=1"  onmousedown="return c({&#39;fm&#39;:&#39;tab&#39;,&#39;tab&#39;:&#39;baike&#39;})">百科</a><a href="http://wenku.baidu.com/search?word=unicode%D7%D6%B7%FB%D6%B5%20%B7%B6%CE%A7&lm=0&od=0"  onmousedown="return c({&#39;fm&#39;:&#39;tab&#39;,&#39;tab&#39;:&#39;wenku&#39;})">文库</a><a href="http://dict.baidu.com/s?wd=unicode%D7%D6%B7%FB%D6%B5%20%B7%B6%CE%A7"  onmousedown="return c({&#39;fm&#39;:&#39;tab&#39;,&#39;tab&#39;:&#39;dict&#39;})">词典</a><p></p><a href="http://www.baidu.com/more/"  onmousedown="return c({&#39;fm&#39;:&#39;tab&#39;,&#39;tab&#39;:&#39;more&#39;})">更多<span>>></span></a></p></p><form name="f" action="s"  class="fm"><input type="hidden" name="tn" value="baiduhome_pg"><input type="hidden" name="bs" value="unicode字符值 范围"><input type="hidden" name="f" value="8"><input type="hidden" name="rsv_bp" value="1"><input name="wd" id="kw" class="i" value="unicode字符值 范围" maxlength="100"><span class="btn_wr"><input type="submit" id="su" value="百度一下" class="btn" onmousedown="this.className=&#39;btn btn_h&#39;" onmouseout="this.className=&#39;btn&#39;"></span><span class="tools"><span id="mHolder"><p id="mCon"><span>输入法</span></p><ul id="mMenu"><li><a href="#" name="ime_hw">手写</a></li><li><a href="#" name="ime_py">拼音</a></li><li class="ln"></li><li><a href="#" name="ime_cl">关闭</a></li></ul></span><span class="seth" id="seth"><strong>推荐 : </strong><a href="#" onClick="h(this)" onmousedown="return ns_c({&#39;fm&#39;:&#39;behs&#39;,&#39;tab&#39;:&#39;homepage&#39;,&#39;pos&#39;:1})">把百度设为主页</a></span>
<span class="setf" id="setf"><strong>推荐 : </strong><a href="javascript:void(0)" onClick="fa(this)" onmousedown="return ns_c({&#39;fm&#39;:&#39;behs&#39;,&#39;tab&#39;:&#39;favorites&#39;,&#39;pos&#39;:1})">把百度加入收藏夹</a></span>
</span></form></p><br>
<p id="container">
<table width="30%" cellpadding="0" cellspacing="0" align="right"><tr>
<td align="left" style="padding-right:10px">
<p style="border-left:1px solid #e1e1e1;padding-left:10px;word-break:break-all;word-wrap:break-word;">
EOT;
$str = strip_tags($str,"");
$str = str_replace(array(&#39; &#39;,"\t","\r\n","\r","\n"),&#39;&#39;,$str);
preg_match_all(&#39;/[\w\s\x{4e00}-\x{9fff}]+/u&#39;, $str, $matches);
$str = implode(&#39;&#39;, $matches[0]);
print_r($str);

                   

                   

声明:
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn