如何过滤文本框js

#1 淡蓝挚爱

博客输入文章标题和内容后输出

比如说在文本框中输入js脚本


怎么过滤啊,这样不安全啊。
表达的不是很清楚,求大神指点。

2013-05-14 23:12:04

#2 jake

strip_tags

2013-05-14 23:23:24

#3 淡蓝挚爱

能解释的详细点吗?jake
就是要屏蔽js,不能老是弹窗

2013-05-14 23:26:18

#4 jake

用php自带的strip_tags函数来过滤内容,Google一下

2013-05-14 23:48:59

#5 sunxch100

我给个例子:$str = strip_tags('html内容');
抄来的,参考一下:

Here is a far better function for the atypical process of stripping tags:

function strip_html_tags( $text )
{
    $text = preg_replace(
        array(
          // Remove invisible content
            '@]*?>.*?@siu',
            '@]*?>.*?@siu',
            '@]*?.*?@siu',
            '@]*?.*?@siu',
            '@]*?.*?@siu',
            '@]*?.*?@siu',
            '@]*?.*?@siu',
            '@]*?.*?@siu',
            '@]*?.*?@siu',
          // Add line breaks before and after blocks
            '@            '@            '@            '@            '@            '@            '@        ),
        array(
            ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ',"$0", "$0", "$0", "$0", "$0", "$0","$0", "$0",), $text );
      
    return strip_html_tags( $text , '' );
}

2013-05-31 16:27:05