• 0
  • 0

PHP字符串过滤

2020-08-03 45 0 admin 所属分类:PHP 记录
$html = file_get_contents($file);
$html = preg_replace( "/<script(.*?)<\/script>/is", "", $html );
$html = preg_replace( "/<iframe(.*?)<\/iframe>/is", "", $html );
$html = preg_replace( "/<style(.*?)<\/style>/is", "", $html );
$html = preg_replace( "/{(.*?)}/is", "", $html );
//过滤多行注释
$html = preg_replace( "/\/\*([\s\S]+?)\*\//", "", $html );
//过滤html注释
$html = preg_replace( "/<!--([\s\S]+?)-->/", "", $html );
//过滤单行注释
$html = preg_replace( "/\/\/(.*?)[\r\n]/", "", $html );
//过滤换行符制表符
$html=preg_replace("/[\t\n\r]+/","",$html);
//过滤特殊字符
$html=str_replace(["-","!","\"","'","!"],"",$html);


返回顶部