据我的估计,原因在于:你在输入正则表达式的时候,可能不是太正确。以下是我的测试过程:
运行访问你的脚本,在文本域里将你的脚本源代码粘上,再在正则表达输入框里输入:
%<input
type(.*)/>%si
你查看网页源代码,其输出结果如下:
<pre>Array
(
[0]
=>
Array
(
[0]
=>
<input
type="submit"
name="button"
value="提交"
/>
)
[1]
=>
Array
(
[0]
=>
="submit"
name="button"
value="提交"
)
)
</pre>
说明,还是匹配到了html标签。
而第1个匹配项,在浏览器里会显示为一个html按钮,原因在于这是正规的html语句,所以,浏览器会将这个表现出来。
一般都是过滤掉单双引号就可以了即使是转义后
也只是把<
转义成
<
当从数据库中读取的时候
输入到页面以后
浏览器就会自动的显示<了
方法/步骤1
htmlspecialchars()转义特别的字符为HTML实体;
'&' (ampersand) becomes '&' '"' (double quote) becomes '"' when ENT_NOQUOTES is not set. ''' (single quote) becomes ''' only when ENT_QUOTES is set. '<' (less than) becomes '<' '>' (greater than) becomes '>'
2
htmlspecialchars_decode()将实体转成HTML代码,函数1的反函数。
3
htmlentities()
这个是全部转换html实体,和htmlspecialchars()区别在于,这个函数是转义全部的字符,而htmlspecialchars()仅仅转义上面限定的5个特殊字符!
html_entity_decode() 函数
把 HTML 实体转换为字符。