(greater than) Syntax htmlspecialchars_decode(str,flags) Parameters str - String flags to decode - specify how quotes are handled and what document type to use. The following is the quote style - ENT_COMPAT - default. Decode double quotes only ENT_QUOTES - Decode double quotes and"/> (greater than) Syntax htmlspecialchars_decode(str,flags) Parameters str - String flags to decode - specify how quotes are handled and what document type to use. The following is the quote style - ENT_COMPAT - default. Decode double quotes only ENT_QUOTES - Decode double quotes and">

Home  >  Article  >  Backend Development  >  htmlspecialchars_decode() function in PHP

htmlspecialchars_decode() function in PHP

WBOY
WBOYforward
2023-09-02 23:25:101933browse

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)

Parameters

  • str - The string to decode

  • flags - 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);
?>

The following is the output -

Output

<p>this -> "keyword in programming language</p>
<p>this -> "keyword in programming language</p>

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!

Statement:
This article is reproduced at:tutorialspoint.com. If there is any infringement, please contact admin@php.cn delete