English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

PHP Basic Tutorial

PHP Advanced Tutorial

PHP & MySQL

PHP Reference Manual

PHP html_entity_decode() Function Usage and Example

PHP String Character String Functions Manual

    The html_entity_decode() function is used to convert HTML entities to their corresponding characters

Syntax

string html_entity_decode ( string $string [, int $flags = ENT_COMPAT | ENT_HTML401 [, string $encoding = ini_get("default_charset") ])

Definition and usage

It is used to convert HTML entities to the application characters

Return value

It returns the decoded string.

Parameter

Serial numberParameters and descriptions
1

string

It contains information about the input string

2

flags

Optional. Specifies how quotes are handled and which document type is used.

Available quote types:

  • ENT_COMPAT - Default. Decode double quotes only.

  • ENT_QUOTES - Decode double quotes and single quotes.

  • ENT_NOQUOTES - Do not decode any quotes.

Additional flags specified for the document type used:

  • ENT_HTML401 - Default. As HTML 4.01 Processing code.

  • ENT_HTML5 - As HTML 5 Processing code.

  • ENT_XML1 - As XML 1 Processing code.

  • ENT_XHTML - As XHTML processing code.

3
Optional. A string that specifies the character set to use.

Allowed values:

  • UTF-8 - Default. ASCII compatible multibyte 8 Bit Unicode

  • ISO-8859-1 - Western European

  • ISO-8859-15 - Western European (including euro symbol + ISO-8859-1 missing French and Finnish letters)

  • cp866 - DOS专用 Cyrillic character set

  • cp1251 - Windows专用 Cyrillic character set

  • cp1252 - Windows专用 Western European character set

  • KOI8-R - Russian

  • BIG5 - Traditional Chinese, mainly used in Taiwan

  • GB2312 - Simplified Chinese, National Standard Character Set

  • BIG5-HKSCS - Big5 with Hong Kong extension5

  • Shift_JIS - Japanese

  • EUC-JP - Japanese

  • MacRoman - Character set used by the Mac operating system

Note:in PHP 5.4 earlier versions, unrecognized character sets will be ignored and replaced by ISO-8859-1 instead. Since PHP 5.4 Starting from PHP-8 instead.

Online Example

Try the following example, convert HTML entities to characters:

<?php
   $input = "w3codebox\".com\" simply <b>easy</b> learning";
   $ab = htmlentities($input);
   $b = html_entity_decode($ab);
   echo $b;
?>
Test and See‹/›

Output Result-

w3codebox ".com" simply <b>easy</b> learning

PHP String Character String Functions Manual