Wednesday, October 1, 2025
HomeLanguagesPHP htmlspecialchars_decode() Function

PHP htmlspecialchars_decode() Function

The htmlspecialchars_decode() function is an inbuilt function in PHP that converts special entities back to characters.

Syntax:

Sttring htmlspecialchars_decode(
    string $string, 
    int $flags = ENT_QUOTES | ENT_SUBSTITUTE | ENT_HTML401
)

Parameters: This function accept two parameters that are discussed below:

  • string: The string to decode.
  • flags: A bitmask of one or more of the following flags, which specify how to handle quotes and which document type to use.

Return Values: This function returns the decoded string.

Example 1: This example illustrates the htmlspecialchars_decode() function.

PHP




<?php
$str = "<p>this -> "</p>\n";
echo htmlspecialchars_decode($str);
?>


Output

<p>this -> "</p>

Program 2: This example illustrates the htmlspecialchars_decode() function.

PHP




<?php
$str = "<p>this -> "</p>\n";
echo htmlspecialchars_decode($str, ENT_NOQUOTES);
?>


Output

<p>this -> "</p>\

Reference: https://www.php.net/manual/en/function.htmlspecialchars-decode.php

RELATED ARTICLES

Most Popular

Dominic
32330 POSTS0 COMMENTS
Milvus
84 POSTS0 COMMENTS
Nango Kala
6703 POSTS0 COMMENTS
Nicole Veronica
11867 POSTS0 COMMENTS
Nokonwaba Nkukhwana
11926 POSTS0 COMMENTS
Shaida Kate Naidoo
6815 POSTS0 COMMENTS
Ted Musemwa
7078 POSTS0 COMMENTS
Thapelo Manthata
6775 POSTS0 COMMENTS
Umr Jansen
6774 POSTS0 COMMENTS