html_entity_decode

FunctionParams changed in PHP 8.1

Convert HTML entities to their corresponding characters.

PHP 5
PHP 7.0
Improved
PHP 7.1-7.4
PHP 8.0
Improved
PHP 8.1
Improved
PHP 8.2
PHP 8.3
PHP 8.4
PHP 8.5

html_entity_decode Function synopsis

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

Parameters

$string

Typestring

The input string.

$flags

OptionalTypeintDefault valueENT_QUOTES | ENT_SUBSTITUTE | ENT_HTML401

A bitmask of one or more of the following flags, which specify how to handle quotes and which document type to use. The default is ENT_QUOTES | ENT_SUBSTITUTE | ENT_HTML401.

$flags accepts one or a bitmask of the following constant values:

$encoding

OptionalType?stringDefault valuenull

Return value

Typestring

Returns the decoded string.

Changes to the html_entity_decode Function

PHP 8.1

  • Parameter default value changed for position #2 ($flags): ENT_COMPAT to ENT_QUOTES | ENT_SUBSTITUTE | ENT_HTML401
  html_entity_decode(
      string $string,
-     int $flags = ENT_COMPAT,
+     int $flags = ENT_QUOTES | ENT_SUBSTITUTE | ENT_HTML401,
      ?string $encoding = null
    ): string

PHP 8.0

  • Return type added: string
  • Parameter type added for parameter #1 ($string): string
  • Parameter name of parameter #2 changed: $quote_style to $flags
  • Parameter type added for parameter #2 ($flags): int
  • Parameter default value added for position #2 ($flags): ENT_COMPAT
  • Parameter type added for parameter #3 ($encoding): ?string
  • Parameter default value added for position #3 ($encoding): null
  html_entity_decode(
-     $string,
+     string $string,
-     $quote_style,
+     int $flags = ENT_COMPAT,
-     $encoding
+     ?string $encoding = null
-   )
+   ): string

PHP 7.0

  • Parameter name of parameter #3 changed: $charset to $encoding
  html_entity_decode(
      $string,
      $quote_style,
-     $charset
+     $encoding
    )

html_entity_decode Function Availability

PHP VersionAvailability
PHP 8.5Future Release Yes
PHP 8.4Upcoming Release Yes
PHP 8.3Supported (Latest) Yes
PHP 8.2Supported Yes
PHP 8.1Security-Fixes Only Yes
PHP 8.0Unsupported Yes
PHP 7.4Unsupported Yes
PHP 7.3Unsupported Yes
PHP 7.2Unsupported Yes
PHP 7.1Unsupported Yes
PHP 7.0Unsupported Yes
PHP 5.6Unsupported Yes
PHP 5.5Unsupported Yes
PHP 5.4Unsupported Yes
PHP 5.3Unsupported Yes