Base di conoscenzaCentro esami
ITItaliano
Scegli la lingua13

CKTIS / PHP

html_entity_decode()

Sostituisce le entità HTML supportate, con nome o numeriche, con caratteri.

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

Sintassi

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

Sostituisce le entità HTML supportate, con nome o numeriche, con caratteri. Il tipo di documento sceglie le entità, le opzioni delle virgolette ne regolano la decodifica ed encoding controlla i byte in uscita. Un passaggio trasforma < in <.

Firma

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

Output dell’esempio

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

Esempi

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

Risultato

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

Fonti