Jump to: navigation, search

Php htmlspecialchars decode

From w3cyberlearnings

Contents

PHP function htmlspecialchars_decode

This function converts special HTML entities back to character.

Syntax htmlspecialchars_decode

  • string: string input contains HTML special entities.
htmlspecialchars_decode(string);

Return

Return encode string.

HTML Entities

  • &lt;: < (less than)
  • &gt;: > (greater than)
  • &amp;: & (ampersand)
  • &quot;: " (double quote)
  • &#039;: ' (single quote)

Example 1

<?php

$str = 'a &gt; than b, but &#039;aa&#039; &lt; than &quot;ab&quot;';
echo htmlspecialchars_decode($str);
?>


Output

a > than b, but 'aa' < than "ab"

Example 2: Do not decode a single quote

<?php

$str = 'a > than b, but 'aa' < than "ab"';
echo htmlspecialchars_decode($str,ENT_COMPAT);
?>


Output

a > than b, but 'aa' < than "ab"
//HTML View Source
a > than b, but &#039;aa&#amp;039; < than "ab"

Related Functions


Navigation
Web
SQL
MISC
References