Knowledge baseExam Center
ENEnglish
Choose language13

CKTIS / PHP

html_entity_decode()

Convert supported named and numeric HTML entities to characters.

Version: PHP 8.4; repository runtime, production runtime not attested

Syntax

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

Convert supported named and numeric HTML entities to characters. The document-type flag selects the entity table, quote flags select which quotes decode, and encoding controls the output bytes. Decoding one layer of < leaves <, not the less-than character.

Signature

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

Example output

["<","'","""]

Examples

<?php
echo json_encode([html_entity_decode("&amp;lt;",ENT_QUOTES|ENT_HTML5,"UTF-8"),html_entity_decode("&apos;",ENT_QUOTES|ENT_HTML5,"UTF-8"),html_entity_decode("&quot;",ENT_NOQUOTES|ENT_HTML5,"UTF-8")]);

Result

["&lt;","'","&quot;"]

Sources