Base de conocimientosCentro de exámenes
ESEspañol
Elegir idioma13

CKTIS / PHP

html_entity_decode()

Sustituye entidades HTML admitidas, con nombre o numéricas, por caracteres.

Versión: PHP 8.4; repository runtime, production runtime not attested

Sintaxis

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

Sustituye entidades HTML admitidas, con nombre o numéricas, por caracteres. El tipo de documento selecciona las entidades, las opciones de comillas regulan su decodificación y encoding fija los bytes de salida. Una pasada convierte < en <.

Firma

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

Salida del ejemplo

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

Ejemplos

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

Fuentes