博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
php----过滤函数
阅读量:4200 次
发布时间:2019-05-26

本文共 1167 字,大约阅读时间需要 3 分钟。

/**

     * Remove HTML tags, including invisible text such as style and
     * script code, and embedded objects.  Add line breaks around
     * block-level tags to prevent word joining after tag removal.
     */
    public function strip_html_tags( $text )
    {
        $text = preg_replace(
            array(
              // Remove invisible content
                '@<head[^>]*?>.*?</head>@siu',
                '@<style[^>]*?>.*?</style>@siu',
                '@<script[^>]*?.*?</script>@siu',
                '@<object[^>]*?.*?</object>@siu',
                '@<embed[^>]*?.*?</embed>@siu',
                '@<applet[^>]*?.*?</applet>@siu',
                '@<noframes[^>]*?.*?</noframes>@siu',
                '@<noscript[^>]*?.*?</noscript>@siu',
                '@<noembed[^>]*?.*?</noembed>@siu',
              // Add line breaks before and after blocks
                '@</?((address)|(blockquote)|(center)|(del))@iu',
                '@</?((div)|(h[1-9])|(ins)|(isindex)|(p)|(pre))@iu',
                '@</?((dir)|(dl)|(dt)|(dd)|(li)|(menu)|(ol)|(ul))@iu',
                '@</?((table)|(th)|(td)|(caption))@iu',
                '@</?((form)|(button)|(fieldset)|(legend)|(input))@iu',
                '@</?((label)|(select)|(optgroup)|(option)|(textarea))@iu',
                '@</?((frameset)|(frame)|(iframe))@iu',
            ),
            array(
                ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ',
                "/n/$0", "/n/$0", "/n/$0", "/n/$0", "/n/$0", "/n/$0",
                "/n/$0", "/n/$0",
            ),
            $text );
        return strip_tags( $text );
    }

转载地址:http://owcli.baihongyu.com/

你可能感兴趣的文章
周末参加“北京干部管理职业技术学院”关于高职课程改革的专家讨论会
查看>>
软件测试框架介绍
查看>>
软件自动化测试框架的发展
查看>>
实现haproxy+LNMT负载均衡架构
查看>>
TensorFlow和keras的前世今生以及keras和tf.keras的对比
查看>>
Keras(一)分类模型实战
查看>>
Keras(二)回归模型实战
查看>>
Keras(三)实现深度神经网络
查看>>
sigmoid函数求导、求极值(史上最详细)
查看>>
Keras(四)实现批标准化、激活函数、dropout
查看>>
Keras(五)wide_deep模型
查看>>
Keras(六)keras模型封装转化为sklearn模型、使用超参数搜索
查看>>
排坑:TypeError: handle_get_file_code() got an unexpected keyword argument ‘save_all‘
查看>>
C++ explict
查看>>
const
查看>>
new & delete
查看>>
《Windows程序设计》第4章
查看>>
VC项目文件说明
查看>>
用Win32实现类似MFC中Draw3dRect函数的功能
查看>>
static、const和static const以及它们的初始化
查看>>