html_entity_decode() function in PHP || PHP html entity decode

html_entity_decode() function in php

Last Updated by Pooja Chikara 03-May-20

0 356


PHP html_entity_decode() function of is used to convert HTML entities to characters. It is an inbuilt function of PHP.

The return type of this function is string means it returns a converted string.

Syntax:

html_entity_decode($string,flags,characters);

here,

1. $string is a PHP string that is decoded by this function. It is mandatory.

2. Flags used to specify the quotes and document types used by the table. It is also an optional parameter. The possible values for this are:

a)  For quotes

  • ENT_COMPAT
  • ENT_QUOTES
  • ENT_NOQUOTES

b)  For document type

  • ENT_HTML401
  • ENT_HTML5
  • ENT_XML1
  • ENT_XHTML

c) Characters specify which type of character set is to be used. It is also optional. Possible values are:

  • UTF-8
  • ISO-8859-1
  • ISO-8859-15
  • cp866
  • cp1251
  • cp1252
  • KOI8-R
  • BIG5
  • GB2312
  • BIG5-HKSCS
  • Shift_JIS
  • EUC-JP
  • MacRoman

Example:

<?php
$string = 'a &lt; b';  // &lt; is HTML entity of less than symbol
$converted_string=html_entity_decode($string);
echo $converted_string;
?>

Output:

html_entity_decode() function in php


Share:


Leave a Reply


Comments
    Waiting for your comments