Encodera

Thanks for reading!

Donate to the site — we work hard for you.

PHP reference

html_entity_decode

Turns HTML entities back into characters.

Syntax

html_entity_decode(string $string, int $flags = ENT_QUOTES | ENT_SUBSTITUTE | ENT_HTML401, ?string $encoding = null): string

Parameters

ParameterTypeDescription
$stringstringA string with entities such as `&`.
$flagsintOptional. Which quotes to convert.
$encoding?stringOptional. The encoding.

Return value

stringA string with regular characters.

Examples

Entities into characters:

<?php
 
echo html_entity_decode('Tom &amp; Jerry &copy; 2025');

Output:

Tom & Jerry © 2025

Notes

The exact reverse of htmlspecialchars() is htmlspecialchars_decode(). Decoded text is unsafe to print on a page again.

See also

Related recipes

In the tutorial

  • Security — The basics of PHP site security — XSS and escaping, SQL injection, password hashing, CSRF tokens and validating input.

Thanks for reading!

Donate to the site — we work hard for you.