PHP Remove JavaScript

前端 未结 7 1690
梦谈多话
梦谈多话 2020-12-03 07:13

I am trying to remove JavaScript from the HTML.

I can\'t get the regular expression to work with PHP; it\'s giving me an null array. Why?



        
相关标签:
7条回答
  • 2020-12-03 08:15

    I use this:

    function clear_text($s) {
        $do = true;
        while ($do) {
            $start = stripos($s,'<script');
            $stop = stripos($s,'</script>');
            if ((is_numeric($start))&&(is_numeric($stop))) {
                $s = substr($s,0,$start).substr($s,($stop+strlen('</script>')));
            } else {
                $do = false;
            }
        }
        return trim($s);
    }
    
    0 讨论(0)
提交回复
热议问题