学习php需要了解的点3

== PHP 特殊字符转换为URL传值的函数 ==

urlencode($stringToUrl);

== PHP 字符串转换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个特殊字符!


猜你喜欢

转载自blog.csdn.net/lwcbest/article/details/38088337
今日推荐