最新消息:本站所有跳转向bbs.ykit.cn的附件将全面停止,附件已转移到https://www.qingsj.com

php针对HTML实体字符的转义函数

PHP 有客 123浏览
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 '&lt;' 
    '>' (greater than) becomes '&gt;' 

2、htmlspecialchars_decode()将实体转成HTML代码,函数1的反函数

3、 htmlentities()这个是全部转换html实体,和htmlspecialchars()区别在于,这个函数是转义全部的字符,而htmlspecialchars()仅仅转义上面限定的5个特殊字符!

转载请注明:有客帮 » php针对HTML实体字符的转义函数