PHP String htmlspecialchars_decode() FunctionThe htmlspecialchars_decode() function is an in-built function of PHP, which converts pre-defined HTML entities to characters. It is opposite to the htmlspecialchars() function. HTML entities decoded back to the character will be like-
The htmlspecialchars_decode() function is used to decode the HTML entities into characters, whereas htmlspecialchars() is used to converts the character in HTML entities. For ExampleHTML output = This is some <i> italic </i> text. Browser output = This is some italic text Syntax:DescriptionParametersstring (mandatory): string is the first parameter of this function, to which we will decode. This parameter is mandatory. flags (optional): flag is the second or last parameter of this function that contains one or more flags constants which states how to handle quotes, and which type of document to be used. By default, they are ENT_COMPAT | ENT_HTML401. Available flags constants are given below in the table:
Value returned by htmlspecialchars_decode()It returns the decoded string. Changelog
Examples of htmlspecialchars_decode()Below some example are given of htmlspecialchars_decode() function. Example 1Browser Output Output on browsers for the above program would be like as given below: HTML Output We can see the html source code for the following program in the browser -> More tools -> Developers tools, and press CTRL+P. It would look in HTML file like- Example 2Browser Output Output on browsers for the above program would be like as given below: HTML Output The HTML view source program would be like- It would be in HTML file like - Example 3Browser Output Output on browsers for the above program would be like as given below: HTML Output The HTML view source program would be like- It would be in HTML file like - Next TopicPHP String Functions |