htmlspecialchars_decode() function in PHP

WBOY
Release: 2023-09-03 06:00:01
forward
1873 people have browsed it

htmlspecialchars_decode() function in PHP

html_special_chars_decode() function is used to convert special HTML entities back to characters.

The following is the HTML entity that will be decoded -

  • & becomes & (ampersand)

  • "changes to" (double quotation mark)

  • & #039; becomes ' (single quotation mark)

  • ##& lt; becomes
  • > becomes > (greater than)

Syntax

htmlspecialchars_decode(str,flags)
Copy after login

Parameters

  • str - The string to decode

  • flags< strong> - Specifies how quotes are handled and the document type to use.

  • The following are quote styles -

    • ENT_COMPAT - Default. Decode only double quotes

    • ENT_QUOTES - Decode double and single quotes

    • ENT_NOQUOTES - Do not decode any quotes

  • Additional flags for specifying the document type used -

    • ENT_HTML401 - Default. Process code as HTML 4.01

    • ##ENT_HTML5 - Process code as HTML 5
    • ENT_XML1 - Process code as XML 1
    • ENT_XHTML - Process code as XHTML
  • Return

htmlspecialchars_decode () function returns the converted string .

The following is an example -

Example

Live demonstration

<?php
$s = "<p>this -> "keyword in programming language</p></p><p>";
echo htmlspecialchars_decode($s);
echo htmlspecialchars_decode($s, ENT_NOQUOTES);
?>
Copy after login

The following is the output -

Output

<p>this -> "keyword in programming language</p>
<p>this -> "keyword in programming language</p>
Copy after login

The above is the detailed content of htmlspecialchars_decode() function in PHP. For more information, please follow other related articles on the PHP Chinese website!

source:tutorialspoint.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!