In PHP 8.3 & PHP 8.4, the `htmlspecialchars_decode()` function is used to convert special HTML entities back to their corresponding characters. This is the reverse of the `htmlspecialchars()` function, which converts special characters to HTML entities.
Syntax:
<?php htmlspecialchars_decode(string $string, int $flags = ENT_COMPAT | ENT_HTML401): string ?>
Example Usage:
<?php // A string with HTML entities $string = "This is a <strong>test</strong> string with "quotes" and & symbols."; // Decode the HTML entities $decodedString = htmlspecialchars_decode($string); echo $decodedString; ?>
Output:
This is a <strong>test</strong> string with "quotes" and & symbols.