DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Snippets has posted 5883 posts at DZone. View Full User Profile

Convert HTML Entities

04.14.2005
| 8621 views |
  • submit to reddit
        Include this to convert those ampersands and angle brackets to proper entities. It can help with XML too but remember there are lots of other entities that need converting. 

use HTML::Entities;

...

$html = encode_entities($string, '<>&"');