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

PHP Basic Tutorial

PHP Advanced Tutorial

PHP & MySQL

PHP Reference Manual

PHP html_special_chars_decode() Function Usage and Example

   PHP String Character String Functions Manual

    The html_special_chars_decode() function is used to convert special HTML entities back to normal characters.

Syntax

string htmlspecialchars_decode ( string $string[, int $flags = ENT_COMPAT | ENT_HTML401 ] )

Definition and Usage

It is used to convert special HTML entities back to characters.

Note: The function performs the opposite action of htmlspecialchars(). It converts special HTML entities back to normal characters.

The following HTML entities will be decoded:

  • & Decoded to & (ampersand)

  • " Decoded to \

  • ' Decoded to ' (single quote)

  • < Decoded to < (less than)

  • > Decoded to > (greater than)

Return Value

It returns the decoded string.

Parameter

Serial NumberParameters and Description
1

string

String to be decoded

2

flags

Specify how quotes are handled and which document type is used.

Available quote types:

  • ENT_COMPAT - Default. Decode double quotes only.

  • ENT_QUOTES - Decode double and single quotes.

  • ENT_NOQUOTES - Do not decode any quotes.

Additional flags for specifying the document type to use:

  • 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.

Online Example

Try the following example to convert predefined HTML entities to double quotes

<?php
    //Predefined HTML Entities Converted to Double Quotes
   $str = "<p>"oldtoolbag.com" -> </p>\n";
   echo htmlspecialchars_decode($str);
?>
Test and See‹/›

Output Result-

"oldtoolbag.com" ->

PHP String Character String Functions Manual