duanliu6083 2011-09-30 12:37
浏览 33

使用php删除特定的html标签

Since I dont want to use stip_tags function of php instead of I want to replace <script> and </script> to empty string so that output should be alert(1).

Input:- <script>alert(1)</script>

Output:- alert(1)

how to achieve it.

  • 写回答

6条回答 默认 最新

  • dongzhong5833 2011-09-30 12:39
    关注

    You can always use strip_tags() with a second parameter containing the allowable tags.

    Alternativly, use...

    preg_replace('/<script>(.*)</script>/i', '$1', $input);
    

    Note, not tested.

    评论

报告相同问题?