Home > Resources > Online Tools > PHP Functions > htmlspecialchars()

Live Sandbox PHP htmlspecialchars() Function

PHP htmlspecialchars() Function
Instructions/Notes

htmlspecialchars($your_string, quotestyle, character-set ) — Convert special characters to HTML entities. The special characters are:

  • & (ampersand) becomes '&'
  • " (double quote) becomes '"'
  • ' (singe quote) becomes '''
  • < (less than) becomes '&lt;'
  • > (greater than) becomes '&gt;'

htmlentities($your_string, quotestyle, character-set ) — Very similar to htmlspecialchars() function. However, all applicable characters having HTML character entity equivalents are translated into these entities.

This tool uses the ENT_QUOTES style with the default character set of ISO-8859-1.




Suggested Reading

PHP Cookbook: Solutions & Examples

Amazon Reviewer:
Great help for someone thrown into the fray
(Amazon Affiliate Link)