Base de conhecimentoCentro de Exames
PT · PTPortuguês (Portugal)
Escolher idioma13

CKTIS / PHP

html_entity_decode()

Substitui as entidades HTML suportadas, com nome ou numéricas, por carateres.

Versão: PHP 8.4; repository runtime, production runtime not attested

Sintaxe

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

Substitui as entidades HTML suportadas, com nome ou numéricas, por carateres. O tipo de documento escolhe as entidades, as opções de aspas controlam a sua descodificação e encoding define os bytes de saída. Uma passagem transforma < em <.

Assinatura

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

Saída do exemplo

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

Exemplos

<?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")]);

Resultado

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

Fontes