阅读背景:

删除HTML和恶意代码,在PHP中留下标点符号和外语

来源:互联网 
function stripAlpha( $item )
{
    $search     = array( 
         '@<script[^>]*?>.*?</script>@si'   // Strip out javascript 
        ,'@<style[^>]*?>.*?</style>@siU'    // Strip style tags properly 
        ,'@<[\/\!]*?[^<>]*?>@si'            // Strip out HTML tags
        ,'@<![\s\S]*?–[ \t\n\r]*>@'         // Strip multi-line comments including CDATA
        ,'/\s{2,}/'
        ,'/(\s){2,}/'
    );
    $pattern    = array(
         '#[^a-zA-Z ]#'                     // Non alpha characters
        ,'/\s+/'                            // More than one whitespace
    );
    $replace    = array(
         ''
        ,' '
    );
    $item = preg_replace( $search, '', html_entity_decode( $item ) );
    $item = trim( preg_replace( $pattern, $replace, strip_tags( $item ) ) );

    return $item;
}
function stripAlpha( $item )
{
    $search     



你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: