PHP过滤html、css函数

2012年12月6日 | 标签: , | 点击: 2830 次

PHP过滤html、css函数,简单的正则式匹配,笔记一下!

function cutstr_html($content) {
    $content = preg_replace ( "/]*>/i", "", $content );
    $content = preg_replace ( "/<\/a>/i", "", $content );
    $content = preg_replace ( "/]*>/i", "", $content );
    $content = preg_replace ( "/<\/div>/i", "", $content );
    $content = preg_replace ( "//i", "", $content );     
    $content = preg_replace ( "/style=.+?['|\"]/i", '', $content );   
    $content = preg_replace ( "/class=.+?['|\"]/i", '', $content ); 
    $content = preg_replace ( "/id=.+?['|\"]/i", '', $content );      
    $content = preg_replace ( "/lang=.+?['|\"]/i", '', $content );     
    $content = preg_replace ( "/width=.+?['|\"]/i", '', $content );    
    $content = preg_replace ( "/height=.+?['|\"]/i", '', $content );   
    $content = preg_replace ( "/border=.+?['|\"]/i", '', $content );   
    $content = preg_replace ( "/face=.+?['|\"]/i", '', $content );  
    $content = preg_replace ( "/face=.+?['|\"]/", '', $content );
    return $content;
}




目前还没有任何评论.

返回顶部