Using the PHP Function html_Entity_Decode
Before PHP 8.1 the htmlspecialchars and htmlentities functions did not convert single quote characters. This meant that when you displayed a string such as "I'll leave tomorrow" in a browser you would see an empty string rather than the actual string. This behavior was changed in PHP 8.1 to substitute invalid characters with (U+FFFD) characters.
The html_entity_decode() function does the opposite of the html_entities() function, it converts an &-escaped string into its original format, reversing the operation of html_entities(). The function takes two arguments, a string to decode and a bitmask of flags that specify how the string should be treated.
If you do not specify a value for this argument then the default values will be used, which are ISO-8859-1 prior to PHP 5.4.0 and UTF-8 afterwards. It is highly recommended that you specify a valid value for this parameter.
In this example we will use ENT_QUOTES, which means that the conversion table will contain entities for double quotes, but not for single ones. We will also use a document type of 'XHTML'.
Lastly we will specify a character set to use, which can be one of the following:
Using ENT_QUOTES with a document type of 'XHTML' will decode all of your characters including