Open In App

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:

Return Values: This function returns the decoded string.



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




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

Output

<p>this -> "</p>

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




<?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

Article Tags :