Name
html_entities()
Synopsis
string html_entities ( stringhtml
[, intoptions
[, stringcharset
]] )
The html_entities()
function converts characters that are illegal in HTML, such as &
, <
, and "
, into their safe equivalents: &
, <
, and "
, respectively.
$flowerpot_men = "Bill & Ben"; $safe_flowerpots = htmlentities($flowerpot_men); // it's now "Bill & Ben"
This method of encoding is often referred to as &-escaping. You can reverse this conversion using the html_entity_decode()
function.
Get PHP in a Nutshell now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.