Esercitazione PHP

PHP HOME Introduzione a PHP Installazione PHP Sintassi PHP Commenti PHP Variabili PHP PHP Eco/Stampa Tipi di dati PHP Stringhe PHP Numeri PHP PHP matematica Costanti PHP Operatori PHP PHP Se...Altro...Altro Passaggio PHP Ciclo PHP Funzioni PHP Matrici PHP Superglobali PHP RegEx PHP

Moduli PHP

Gestione dei moduli PHP Convalida del modulo PHP Modulo PHP richiesto URL/e-mail del modulo PHP Modulo PHP completo

PHP avanzato

Data e ora PHP PHP Include Gestione dei file PHP Apri/Leggi file PHP Creazione/scrittura di file PHP Caricamento file PHP Cookie PHP Sessioni PHP Filtri PHP Filtri PHP avanzati Funzioni di callback PHP PHP JSON Eccezioni PHP

PHP OOP

PHP Che cos'è OOP Classi/Oggetti PHP Costruttore PHP PHP distruttore Modificatori di accesso PHP Ereditarietà PHP Costanti PHP Classi astratte PHP Interfacce PHP Tratti PHP Metodi statici PHP Proprietà statiche PHP Spazi dei nomi PHP Iterabili PHP

Database MySQL

Database MySQL MySQL Connect MySQL Crea DB MySQL Crea tabella Dati di inserimento MySQL MySQL Ottieni l'ultimo ID MySQL inserisce più MySQL preparato MySQL Seleziona dati MySQL dove MySQL Ordina per MySQL Elimina dati Dati di aggiornamento MySQL Dati limite MySQL

PHP XML

Parser XML PHP Analizzatore PHP SimpleXML PHP SimpleXML - Ottieni PHP XML espatriato PHP XML DOM

PHP - AJAX

Introduzione all'Ajax AJAX PHP Database AJAX XML AJAX Ricerca in tempo reale AJAX Sondaggio AJAX

Esempi PHP

Esempi PHP compilatore PHP Quiz PHP Esercizi PHP Certificato PHP

Riferimento PHP

Panoramica di PHP matrice PHP Calendario PHP Data PHP Directory PHP Errore PHP Eccezione PHP File system PHP Filtro PHP PHP FTP PHP JSON Parole chiave PHP PHP Libxml Posta PHP PHP matematica PHP Varie PHP MySQLi Rete PHP Controllo dell'output PHP RegEx PHP PHP SimpleXML Flusso PHP Stringa PHP Gestione delle variabili PHP Analizzatore XML PHP Zip PHP Fuso orario PHP

PHP html_entity_decode() Funzione

❮ Riferimento alla stringa PHP

Esempio

Converti entità HTML in caratteri:

<?php
$str = '&lt;a href=&quot;https://www.w3schools.com&quot;&gt;w3schools.com&lt;/a&gt;';
echo html_entity_decode($str);
?>

L'output HTML del codice sopra sarà (Visualizza sorgente):

<a href="https://www.w3schools.com">w3schools.com</a>

L'output del browser del codice sopra sarà:



Definizione e utilizzo

La funzione html_entity_decode() converte le entità HTML in caratteri.

La funzione html_entity_decode() è l'opposto di htmlentities() .


Sintassi

html_entity_decode(string,flags,character-set)

Valori dei parametri

Parameter Description
string Required. Specifies the string to decode
flags Optional. Specifies how to handle quotes and which document type to use.

The available quote styles are:

  • ENT_COMPAT - Default. Decodes only double quotes
  • ENT_QUOTES - Decodes double and single quotes
  • ENT_NOQUOTES - Does not decode any quotes

Additional flags for specifying the used doctype:

  • ENT_HTML401 - Default. Handle code as HTML 4.01
  • ENT_HTML5 - Handle code as HTML 5
  • ENT_XML1 - Handle code as XML 1
  • ENT_XHTML - Handle code as XHTML
character-set Optional. A string that specifies which character-set to use.

Allowed values are:

  • UTF-8 - Default. ASCII compatible multi-byte 8-bit Unicode
  • ISO-8859-1 - Western European
  • ISO-8859-15 - Western European (adds the Euro sign + French and Finnish letters missing in ISO-8859-1)
  • cp866 - DOS-specific Cyrillic charset
  • cp1251 - Windows-specific Cyrillic charset
  • cp1252 - Windows specific charset for Western European
  • KOI8-R - Russian
  • BIG5 - Traditional Chinese, mainly used in Taiwan
  • GB2312 - Simplified Chinese, national standard character set
  • BIG5-HKSCS - Big5 with Hong Kong extensions
  • Shift_JIS - Japanese
  • EUC-JP - Japanese
  • MacRoman - Character-set that was used by Mac OS

Note: Unrecognized character-sets will be ignored and replaced by ISO-8859-1 in versions prior to PHP 5.4. As of PHP 5.4, it will be ignored an replaced by UTF-8.



Dettagli tecnici

Valore di ritorno: Restituisce la stringa convertita
Versione PHP: 4.3.0+
Registro delle modifiche: PHP 5.6 - Modificato il valore predefinito per il parametro del set di caratteri nel valore del set di caratteri predefinito (nella configurazione).
PHP 5.4 - Modificato il valore predefinito per il parametro del set di caratteri in UTF-8.
PHP 5.4 - Aggiunti ENT_HTML401, ENT_HTML5, ENT_XML1 e ENT_XHTML.
PHP 5.0 - Aggiunto supporto per codifiche multi-byte

Altri esempi

Esempio

Converti alcune entità HTML in caratteri:

<?php
$str = "Albert Einstein said: &#039;E=MC&sup2;&#039;";
echo html_entity_decode($str, ENT_COMPAT); // Will only convert double quotes
echo "<br>";
echo html_entity_decode($str, ENT_QUOTES); // Converts double and single quotes
echo "<br>";
echo html_entity_decode($str, ENT_NOQUOTES); // Does not convert any quotes
?>

L'output HTML del codice sopra sarà (Visualizza sorgente):

Albert Einstein said: &#039;E=MC²&#039;<br>
Albert Einstein said: 'E=MC²'<br>
Albert Einstein said: &#039;E=MC²&#039;

L'output del browser del codice sopra sarà:

Albert Einstein said: 'E=MC²'
Albert Einstein said: 'E=MC²'
Albert Einstein said: 'E=MC²'

Esempio

Converti alcune entità HTML in caratteri, utilizzando il set di caratteri dell'Europa occidentale:

<?php
$str = "My name is &Oslash;yvind &Aring;sane. I&#039;m Norwegian.";
echo html_entity_decode($str, ENT_QUOTES, "UTF-8");
?>

L'output HTML del codice sopra sarà (Visualizza sorgente):

My name is Øyvind Åsane. I'm Norwegian.

L'output del browser del codice sopra sarà:

My name is Øyvind Åsane. I'm Norwegian.


❮ Riferimento alla stringa PHP