← All built-ins / htmlentities()

htmlentities()

htmlentities(string $s): string

Parameters

NameTypeDescription
$sstringtext to escape

Return value

The text with HTML-critical characters converted to entities.

Example

echo htmlentities("<b>Tom & Jerry</b>");
&lt;b&gt;Tom &amp; Jerry&lt;/b&gt;

See also

htmlspecialchars()html_entity_decode()strip_tags()