Encodera

Thanks for reading!

Donate to the site — we work hard for you.

PHP reference

htmlspecialchars_decode

Converts the `<`, `>`, `&`, `"` entities back to characters.

Syntax

htmlspecialchars_decode(string $string, int $flags = ENT_QUOTES | ENT_SUBSTITUTE | ENT_HTML401): string

Parameters

ParameterTypeDescription
$stringstringA string with entities.
$flagsintOptional. How to treat quotes.

Return value

stringThe string with regular characters.

Examples

The reverse conversion:

<?php
 
echo htmlspecialchars_decode('Tom &amp; Jerry &lt;3');

Output:

Tom & Jerry <3

Notes

Keep data in the database in its original form and escape only on output — then no reverse conversion is needed.

See also

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.