去除所有HTML标记、JavaScript标记、换行、空格

 function replaceHtmlAndJs($document)

{

$document=trim($document);

if (strlen($document) <= 0) return $document;

$search=array("'<script[^>]*?>.*?</script>'si","'<[\/\!]*?[^<>]*?>'si","'([\r\n])[\s]+'","'&(quot|#34);'i","'&(amp|#38);'i","'&(lt|#60);'i","'&(gt|#62);'i","'&(nbsp|#160);'i","' 'i","' 'i");

$replac=array("","","","\"","&","<",">","","","");

return @preg_replace ($search, $replac, $document);

}

相关内容推荐

返回
顶部