htmlspecialchars() why does not work on some chars [closed]
hi i was wondering but may开发者_Go百科be i missed up somenthing about htmlspecialchars()
, why does this function does not a replacement of all this html special character
html special chars list
cause for example the char %
is not replaced as i can see
the php manual says about:
'&' (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 '>'
so about other chars ? no function to replace them all?
The manual tells you everything you need to know:
Certain characters have special significance in HTML, and should be represented by HTML entities if they are to preserve their meanings. This function returns a string with some of these conversions made; the translations made are those most useful for everyday web programming. If you require all HTML character entities to be translated, use
htmlentities()
instead.This function is useful in preventing user-supplied text from containing HTML markup, such as in a message board or guest book application.
The translations performed are:
- '
&
' (ampersand) becomes '&
'- '
"
' (double quote) becomes '"
' whenENT_NOQUOTES
is not set.- "
'
" (single quote) becomes ''
' only whenENT_QUOTES
is set.- '
<
' (less than) becomes '<
'- '
>
' (greater than) becomes '>
'
精彩评论