These functions perform replacements on certain characters as shown in the table futher down the page and described briefly here:
- The encodeURIComponent function is an extension of encodeURI, the difference being that it also escapes the following characters: , / ? : @ & = + $
- On the PHP side of things, the only difference beween urlencode and rawurlencode is that the latter escapes the <space> character wheras urlencode uses the widely accepted + instead.
- The htmlentities function escapes characters which have special meaning inside HTML by inserting HTML entities in their place (eg. & in place of &). See our article on ASCII Character Codes for more details.
- All functions have a complementary 'decode' function that pretty much does the opposite.
Escaping Double and Single Quotes
... onclick="return confirm('Delete this item: <?PHP echo addslashes(htmlspecialchars($name)) ?>?';" ...
Table of encoded characters
The RFC 1738 specifications make fascinating reading - considering that the document is 10 years old yet still applicable.