What is the difference between htmlentities and htmlspecialchars in php?

What are the differences between htmlspecialchars() and htmlentities(). When should I use one or the other?

What is the difference between htmlentities and htmlspecialchars in php?

asked Sep 5, 2008 at 18:29

0

htmlspecialchars may be used:

  1. When there is no need to encode all characters which have their HTML equivalents.

    If you know that the page encoding match the text special symbols, why would you use htmlentities? htmlspecialchars is much straightforward, and produce less code to send to the client.

    For example:

    echo htmlentities('.');
    // Output: <Il était une fois un être>.
    //                ^^^^^^^^                 ^^^^^^^
    
    echo htmlspecialchars('.');
    // Output: <Il était une fois un être>.
    //                ^                 ^
    

    The second one is shorter, and does not cause any problems if ISO-8859-1 charset is set.

  2. When the data will be processed not only through a browser (to avoid decoding HTML entities),

  3. If the output is XML (see the answer by Artefacto).

answered Sep 1, 2010 at 1:00

Arseni MourzenkoArseni Mourzenko

48.6k34 gold badges108 silver badges191 bronze badges

1

From the PHP documentation for htmlentities:

This function is identical to htmlspecialchars() in all ways, except with htmlentities(), all characters which have HTML character entity equivalents are translated into these entities.

From the PHP documentation for htmlspecialchars:

Certain characters have special significance in HTML, and should be represented by HTML entities if they are to preserve their meanings. This function returns a string with some of these conversions made; the translations made are those most useful for everyday web programming. If you require all HTML character entities to be translated, use htmlentities() instead.

The difference is what gets encoded. The choices are everything (entities) or "special" characters, like ampersand, double and single quotes, less than, and greater than (specialchars).

I prefer to use htmlspecialchars whenever possible.

For example:

    echo htmlentities('.');
    // Output: <Il était une fois un être>.
    //                ^^^^^^^^                 ^^^^^^^

    echo htmlspecialchars('.');
    // Output: <Il était une fois un être>.
    //                ^                 ^

answered Sep 5, 2008 at 18:31

What is the difference between htmlentities and htmlspecialchars in php?

Thomas OwensThomas Owens

112k96 gold badges306 silver badges430 bronze badges

18

This is being encoded with htmlentities.

implode( "\t", array_values( get_html_translation_table( HTML_ENTITIES ) ) ):

" & < >
¡ ¢ £ ¤ ¥ ¦ § ¨ © ª « ¬ ­ ® ¯ ° ± ² ³ ´ µ ¶ · ¸ ¹ º » ¼ ½ ¾ ¿ À Á Â Ã Ä Å Æ Ç È É Ê Ë Ì Í Î Ï Ð Ñ Ò Ó Ô Õ Ö × Ø Ù Ú Û Ü Ý Þ ß à á â ã ä å æ ç è é ê ë ì í î ï ð ñ ò ó ô õ ö ÷ ø ù ú û ü ý þ ÿ Œ œ Š š Ÿ ƒ ˆ ˜ Α Β Γ Δ Ε Ζ Η Θ Ι Κ Λ Μ Ν Ξ Ο Π Ρ Σ Τ Υ Φ Χ Ψ Ω α β γ δ ε ζ η θ ι κ λ μ ν ξ ο π ρ ς σ τ υ φ χ ψ ω ϑ ϒ ϖ ‌ ‍ ‎ ‏ – — ‘ ’ ‚ “ ” „ † ‡ • … ‰ ′ ″ ‹ › ‾ ⁄ € ℑ ℘ ℜ ™ ℵ ← ↑ → ↓ ↔ ↵ ⇐ ⇑ ⇒ ⇓ ⇔ ∀ ∂ ∃ ∅ ∇ ∈ ∉ ∋ ∏ ∑ − ∗ √ ∝ ∞ ∠ ∧ ∨ ∩ ∪ ∫ ∴ ∼ ≅ ≈ ≠ ≡ ≤ ≥ ⊂ ⊃ ⊄ ⊆ ⊇ ⊕ ⊗ ⊥ ⋅ ⌈ ⌉ ⌊ ⌋ ⟨ ⟩ ◊ ♠ ♣ ♥ ♦

This is being encoded with htmlspecialchars.

implode( "\t", array_values( get_html_translation_table( HTML_SPECIALCHARS ) ) ):

" & < >

answered Jun 22, 2014 at 12:48

What is the difference between htmlentities and htmlspecialchars in php?

BerkyBerky

1,1811 gold badge7 silver badges9 bronze badges

4

Because:

  • Sometimes you're writing XML data, and you can't use HTML entities in a XML file.
  • Because htmlentities substitutes more characters than htmlspecialchars. This is unnecessary, makes the PHP script less efficient and the resulting HTML code less readable.

htmlentities is only necessary if your pages use encodings such as ASCII or LATIN-1 instead of UTF-8 and you're handling data with an encoding different from the page's.

answered Sep 1, 2010 at 0:57

ArtefactoArtefacto

94.2k16 gold badges194 silver badges221 bronze badges

0

You should use htmlspecialchars($strText, ENT_QUOTES) when you just want your string to be XML and HTML safe:

For example, encode

  • & to &
  • " to "
  • < to <
  • > to >
  • ' to '

However, if you also have additional characters that are Unicode or uncommon symbols in your text then you should use htmlentities() to ensure they show up properly in your HTML page.

Notes:

  • ' will only be encoded by htmlspecialchars() to ' if the ENT_QUOTES option is passed in. ' is safer to use then ' since older versions of Internet Explorer do not support the ' entity.
  • Technically, > does not need to be encoded as per the XML specification, but it is usually encoded too for consistency with the requirement of < being encoded.

What is the difference between htmlentities and htmlspecialchars in php?

answered Aug 22, 2012 at 18:38

KmeixnerKmeixner

1,5544 gold badges20 silver badges32 bronze badges

1

htmlspecialchars () does the minimum amount of encoding to ensure that your string is not parsed as HTML. This leaves your string more human-readable than it would be if you used htmlentities () to encode absolutely everything that has an encoding.

answered Sep 1, 2010 at 0:58

grossvogelgrossvogel

6,6441 gold badge24 silver badges36 bronze badges

I just found out about the get_html_translation_table function. You pass it HTML_ENTITIES or HTML_SPECIALCHARS and it returns an array with the characters that will be encoded and how they will be encoded.

What is the difference between htmlentities and htmlspecialchars in php?

Ry-

211k54 gold badges441 silver badges455 bronze badges

answered Apr 6, 2011 at 17:38

Eric HogueEric Hogue

8,6004 gold badges24 silver badges20 bronze badges

1

htmlentities — Convert all applicable characters to HTML entities.

htmlspecialchars — Convert special characters to HTML entities.

The translations performed translation characters on the below:

  • '&' (ampersand) becomes '&'
  • '"' (double quote) becomes '"' when ENT_NOQUOTES is not set.
  • "'" (single quote) becomes ''' (or ') only when ENT_QUOTES is set.
  • '<' (less than) becomes '<'
  • '>' (greater than) becomes '>'

You can check the following code for more information about what's htmlentities and htmlspecialchars:

https://gist.github.com/joko-wandiro/f5c935708d9c37d8940b

G-Nugget

8,4861 gold badge25 silver badges31 bronze badges

answered May 11, 2015 at 3:05

What is the difference between htmlentities and htmlspecialchars in php?

Joko WandiroJoko Wandiro

1,9371 gold badge17 silver badges27 bronze badges

You probably want to use some Unicode character encoding, for example UTF-8, and htmlspecialchars. Because there isn't any need to generate "HTML entities" for "all [the] applicable characters" (that is what htmlentities does according to the documentation) if it's already in your character set.

What is the difference between htmlentities and htmlspecialchars in php?

answered Sep 5, 2008 at 18:39

ciccic

7,1483 gold badges23 silver badges34 bronze badges

The differences between htmlspecialchars() and htmlentities() is very small. Lets see some examples:

htmlspecialchars

htmlspecialchars(string $string) takes multiple arguments where as the first argument is a string and all other arguments (certain flags, certain encodings etc. ) are optional. htmlspecialchars converts special characters in the string to HTML entities. For example if you have < br > in your string, htmlspecialchars will convert it into < b >. Whereas characters like µ † etc. have no special significance in HTML. So they will be not converted to HTML entities by htmlspecialchars function as shown in the below example.

echo htmlspecialchars('An example 
'); // This will print - An example < br > echo htmlspecialchars('µ †'); // This will print - µ †

htmlentities

htmlentities ( string $string) is very similar to htmlspecialchars and takes multiple arguments where as the first argument is a string and all other arguments are optional (certain flags, certain encodings etc.). Unlike htmlspecialchars, htmlentities converts not only special characters in the string to HTML entities but all applicable characters to HTML entities.

echo htmlentities('An example 
'); // This will print - An example < br > echo htmlentities('µ †'); // This will print - µ †

answered Oct 6, 2018 at 11:08

N RandhawaN Randhawa

8,0133 gold badges41 silver badges47 bronze badges

One small example, I needed to have 2 client names indexed in a function:

[1] => Altisoxxce Soluxxons S.à r.l.
[5] => Joxxson & Joxxson

I originally $term = get_term_by('name', htmlentities($name), 'client'); which resulted in term names that only included the ampersand array item (&) but not the accented item. But when I changed the variable setting to htmlspecialchars both were able to run through the function. Hope this helps!

answered Feb 2, 2016 at 6:02

learn2reidlearn2reid

1701 silver badge5 bronze badges

0

**HTML Character Entity Reference Chart at W3.org**

https://dev.w3.org/html5/html-author/charref

	


!
!
"
" "
#
#
$
$
%
%
&
& &
'
'
(
(
)
)
*
* *
+
+
,
,
.
.
/
/
:
:
;
;
<
< <
=
=
>
> >
?
?
@
@
[
[ [
\
\
]
] ]
^
^
_
_
`
` `
{
{ {
|
| | |
}
} }

   
¡
¡
¢
¢
£
£
¤
¤
¥
¥
¦
¦
§
§
¨
¨ ¨ ¨ ¨
©
© ©
ª
ª
«
«
¬
¬
­
®
® ® ®
¯
¯ ‾ ¯
°
°
±
± ± ±
²
²
³
³
´
´ ´
µ
µ
¶
¶
·
· · ·
¸
¸ ¸
¹
¹
º
º
»
»
¼
¼
½
½ ½
¾
¾
¿
¿
À
À
Á
Á
Â
Â
Ã
Ã
Ä
Ä
Å
Å
Æ
Æ
Ç
Ç
È
È
É
É
Ê
Ê
Ë
Ë
Ì
Ì
Í
Í
Î
Î
Ï
Ï
Ð
Ð
Ñ
Ñ
Ò
Ò
Ó
Ó
Ô
Ô
Õ
Õ
Ö
Ö
×
×
Ø
Ø
Ù
Ù
Ú
Ú
Û
Û
Ü
Ü
Ý
Ý
Þ
Þ
ß
ß
à
à
á
á
â
â
ã
ã
ä
ä
å
å
æ
æ
ç
ç
è
è
é
é
ê
ê
ë
ë
ì
ì
í
í
î
î
ï
ï
ð
ð
ñ
ñ
ò
ò
ó
ó
ô
ô
õ
õ
ö
ö
÷
÷ ÷
ø
ø
ù
ù
ú
ú
û
û
ü
ü
ý
ý
þ
þ
ÿ
ÿ
Ā
Ā
ā
ā
Ă
Ă
ă
ă
Ą
Ą
ą
ą
Ć
Ć
ć
ć
Ĉ
Ĉ
ĉ
ĉ
Ċ
Ċ
ċ
ċ
Č
Č
č
č
Ď
Ď
ď
ď
Đ
Đ
đ
đ
Ē
Ē
ē
ē
Ė
Ė
ė
ė
Ę
Ę
ę
ę
Ě
Ě
ě
ě
Ĝ
Ĝ
ĝ
ĝ
Ğ
Ğ
ğ
ğ
Ġ
Ġ
ġ
ġ
Ģ
Ģ
Ĥ
Ĥ
ĥ
ĥ
Ħ
Ħ
ħ
ħ
Ĩ
Ĩ
ĩ
ĩ
Ī
Ī
ī
ī
Į
Į
į
į
İ
İ
ı
ı ı
IJ
IJ
ij
ij
Ĵ
Ĵ
ĵ
ĵ
Ķ
Ķ
ķ
ķ
ĸ
ĸ
Ĺ
Ĺ
ĺ
ĺ
Ļ
Ļ
ļ
ļ
Ľ
Ľ
ľ
ľ
Ŀ
Ŀ
ŀ
ŀ
Ł
Ł
ł
ł
Ń
Ń
ń
ń
Ņ
Ņ
ņ
ņ
Ň
Ň
ň
ň
ʼn
ʼn
Ŋ
Ŋ
ŋ
ŋ
Ō
Ō
ō
ō
Ő
Ő
ő
ő
Œ
Œ
œ
œ
Ŕ
Ŕ
ŕ
ŕ
Ŗ
Ŗ
ŗ
ŗ
Ř
Ř
ř
ř
Ś
Ś
ś
ś
Ŝ
Ŝ
ŝ
ŝ
Ş
Ş
ş
ş
Š
Š
š
š
Ţ
Ţ
ţ
ţ
Ť
Ť
ť
ť
Ŧ
Ŧ
ŧ
ŧ
Ũ
Ũ
ũ
ũ
Ū
Ū
ū
ū
Ŭ
Ŭ
ŭ
ŭ
Ů
Ů
ů
ů
Ű
Ű
ű
ű
Ų
Ų
ų
ų
Ŵ
Ŵ
ŵ
ŵ
Ŷ
Ŷ
ŷ
ŷ
Ÿ
Ÿ
Ź
Ź
ź
ź
Ż
Ż
ż
ż
Ž
Ž
ž
ž
ƒ
ƒ
Ƶ
Ƶ
ǵ
ǵ
ȷ
ȷ
ˆ
ˆ
ˇ
ˇ ˇ
˘
˘ ˘
˙
˙ ˙
˚
˚
˛
˛
˜
˜ ˜
˝
˝ ˝
̑
̑
̲
_
Α
Α
Β
Β
Γ
Γ
Δ
Δ
Ε
Ε
Ζ
Ζ
Η
Η
Θ
Θ
Ι
Ι
Κ
Κ
Λ
Λ
Μ
Μ
Ν
Ν
Ξ
Ξ
Ο
Ο
Π
Π
Ρ
Ρ
Σ
Σ
Τ
Τ
Υ
Υ
Φ
Φ
Χ
Χ
Ψ
Ψ
Ω
Ω
α
α
β
β
γ
γ
δ
δ
ε
ϵ ϵ ε
ζ
ζ
η
η
θ
θ
ι
ι
κ
κ
λ
λ
μ
μ
ν
ν
ξ
ξ
ο
ο
π
π
ρ
ρ
ς
ς ς ς
σ
σ
τ
τ
υ
υ υ
φ
φ ϕ ϕ
χ
χ
ψ
ψ
ω
ω
ϑ
ϑ ϑ ϑ
ϒ
ϒ ϒ
ϕ
ϕ
ϖ
ϖ ϖ
Ϝ
Ϝ
ϝ
ϝ ϝ
ϰ
ϰ ϰ
ϱ
ϱ ϱ
ϵ
ε ϵ
϶
϶ ϶
Ё
Ё
Ђ
Ђ
Ѓ
Ѓ
Є
Є
Ѕ
Ѕ
І
І
Ї
Ї
Ј
Ј
Љ
Љ
Њ
Њ
Ћ
Ћ
Ќ
Ќ
Ў
Ў
Џ
Џ
А
А
Б
Б
В
В
Г
Г
Д
Д
Е
Е
Ж
Ж
З
З
И
И
Й
Й
К
К
Л
Л
М
М
Н
Н
О
О
П
П
Р
Р
С
С
Т
Т
У
У
Ф
Ф
Х
Х
Ц
Ц
Ч
Ч
Ш
Ш
Щ
Щ
Ъ
Ъ
Ы
Ы
Ь
Ь
Э
Э
Ю
Ю
Я
Я
а
а
б
б
в
в
г
г
д
д
е
е
ж
ж
з
з
и
и
й
й
к
к
л
л
м
м
н
н
о
о
п
п
р
р
с
с
т
т
у
у
ф
ф
х
х
ц
ц
ч
ч
ш
ш
щ
щ
ъ
ъ
ы
ы
ь
ь
э
э
ю
ю
я
я
ё
ё
ђ
ђ
ѓ
ѓ
є
є
ѕ
ѕ
і
і
ї
ї
ј
ј
љ
љ
њ
њ
ћ
ћ
ќ
ќ
ў
ў
џ
џ
 
 
 
 
 
 
 
 
 
 
 
 
 
   
 
   
​
​ ​ ​ ​ ​
‌
‌
‍
‍
‎
‎
‏
‏
‐
‐ ‐
–
–
—
—
―
―
‖
‖ ‖
‘
‘ ‘
’
’ ’ ’
‚
‚ ‚
“
“ “
”
” ” ”
„
„ „
†
†
‡
‡ ‡
•
• •
‥
‥
…
… …
‰
‰
‱
‱
′
′
″
″
‴
‴
‵
‵ ‵
‹
‹
›
›
‾
‾
⁁
⁁
⁃
⁃
⁄
⁄
⁏
⁏
⁗
⁗
 
 
⁠
⁠
⁡
⁡ ⁡
⁢
⁢ ⁢
⁣
⁣ ⁣
€
€
⃛
⃛ ⃛
⃜
⃜
ℂ
ℂ ℂ
℅
℅
ℊ
ℊ
ℋ
ℋ ℋ ℋ
ℌ
ℌ ℌ
ℍ
ℍ ℍ
ℎ
ℎ
ℏ
ℏ ℏ ℏ ℏ
ℐ
ℐ ℐ
ℑ
ℑ ℑ ℑ ℑ
ℒ
ℒ ℒ ℒ
ℓ
ℓ
ℕ
ℕ ℕ
№
№
℗
℗
℘
℘ ℘
ℙ
ℙ ℙ
ℚ
ℚ ℚ
ℛ
ℛ ℛ
ℜ
ℜ ℜ ℜ ℜ
ℝ
ℝ ℝ
℞
℞
™
™ ™
ℤ
ℤ ℤ
Ω
Ω
℧
℧
ℨ
ℨ ℨ
℩
℩
Å
Å
ℬ
ℬ ℬ ℬ
ℭ
ℭ ℭ
ℯ
ℯ
ℰ
ℰ ℰ
ℱ
ℱ ℱ
ℳ
ℳ ℳ ℳ
ℴ
ℴ ℴ ℴ
ℵ
ℵ ℵ
ℶ
ℶ
ℷ
ℷ
ℸ
ℸ
ⅅ
ⅅ ⅅ
ⅆ
ⅆ ⅆ
ⅇ
ⅇ ⅇ ⅇ
ⅈ
ⅈ ⅈ
⅓
⅓
⅔
⅔
⅕
⅕
⅖
⅖
⅗
⅗
⅘
⅘
⅙
⅙
⅚
⅚
⅛
⅛
⅜
⅜
⅝
⅝
⅞
⅞
←
← ← ← ← ←
↑
↑ ↑ ↑ ↑
→
→ → → → →
↓
↓ ↓ ↓ ↓
↔
↔ ↔ ↔
↕
↕ ↕ ↕
↖
↖ ↖ ↖
↗
↗ ↗ ↗
↘
↘ ↘ ↘
↙
↙ ↙ ↙
↚
↚ ↚
↛
↛ ↛
↝
↝ ↝
↞
↞ ↞
↟
↟
↠
↠ ↠
↡
↡
↢
↢ ↢
↣
↣ ↣
↤
↤ ↤
↥
↥ ↥
↦
↦ ↦ ↦
↧
↧ ↧
↩
↩ ↩
↪
↪ ↪
↫
↫ ↫
↬
↬ ↬
↭
↭ ↭
↮
↮ ↮
↰
↰ ↰
↱
↱ ↱
↲
↲
↳
↳
↵
↵
↶
↶ ↶
↷
↷ ↷
↺
↺ ↺
↻
↻ ↻
↼
↼ ↼ ↼
↽
↽ ↽ ↽
↾
↾ ↾ ↾
↿
↿ ↿ ↿
⇀
⇀ ⇀ ⇀
⇁
⇁ ⇁ ⇁
⇂
⇂ ⇂ ⇂
⇃
⇃ ⇃ ⇃
⇄
⇄ ⇄ ⇄
⇅
⇅ ⇅
⇆
⇆ ⇆ ⇆
⇇
⇇ ⇇
⇈
⇈ ⇈
⇉
⇉ ⇉
⇊
⇊ ⇊
⇋
⇋ ⇋ ⇋
⇌
⇌ ⇌ ⇌
⇍
⇍ ⇍
⇎
⇎ ⇎
⇏
⇏ ⇏
⇐
⇐ ⇐ ⇐
⇑
⇑ ⇑ ⇑
⇒
⇒ ⇒ ⇒ ⇒
⇓
⇓ ⇓ ⇓
⇔
⇔ ⇔ ⇔ ⇔
⇕
⇕ ⇕ ⇕
⇖
⇖
⇗
⇗
⇘
⇘
⇙
⇙
⇚
⇚ ⇚
⇛
⇛ ⇛
⇝
⇝
⇤
⇤ ⇤
⇥
⇥ ⇥
⇵
⇵ ⇵
⇽
⇽
⇾
⇾
⇿
⇿
∀
∀ ∀
∁
∁ ∁
∂
∂ ∂
∃
∃ ∃
∄
∄ ∄ ∄
∅
∅ ∅ ∅ ∅
∇
∇ ∇
∈
∈ ∈ ∈ ∈
∉
∉ ∉ ∉
∋
∋ ∋ ∋ ∋
∌
∌ ∌ ∌
∏
∏ ∏
∐
∐ ∐
∑
∑ ∑
−
−
∓
∓ ∓ ∓
∔
∔ ∔
∖
∖ ∖ ∖ ∖ ∖
∗
∗
∘
∘ ∘
√
√ √
∝
∝ ∝ ∝ ∝ ∝
∞
∞
∟
∟
∠
∠ ∠
∡
∡ ∡
∢
∢
∣
∣ ∣ ∣ ∣
∤
∤ ∤ ∤ ∤
∥
∥ ∥ ∥ ∥ ∥
∦
∦ ∦ ∦ ∦ ∦
∧
∧ ∧
∨
∨ ∨
∩
∩
∪
∪
∫
∫ ∫
∬
∬
∭
∭ ∭
∮
∮ ∮ ∮
∯
∯ ∯
∰
∰
∱
∱
∲
∲ ∲
∳
∳ ∳
∴
∴ ∴ ∴
∵
∵ ∵ ∵
∶
∶
∷
∷ ∷
∸
∸ ∸
∺
∺
∻
∻
∼
∼ ∼ ∼ ∼
∽
∽ ∽
∾
∾ ∾
∿
∿
≀
≀ ≀ ≀
≁
≁ ≁
≂
≂ ≂ ≂
≃
≃ ≃ ≃
≄
≄ ≄ ≄
≅
≅ ≅
≆
≆
≇
≇ ≇
≈
≈ ≈ ≈ ≈ ≈ ≈
≉
≉ ≉ ≉
≊
≊ ≊
≋
≋
≌
≌ ≌
≍
≍ ≍
≎
≎ ≎ ≎
≏
≏ ≏ ≏
≐
≐ ≐ ≐
≑
≑ ≑
≒
≒ ≒
≓
≓ ≓
≔
≔ ≔ ≔
≕
≕ ≕
≖
≖ ≖
≗
≗ ≗
≙
≙
≚
≚
≜
≜ ≜
≟
≟ ≟
≠
≠ ≠
≡
≡ ≡
≢
≢ ≢
≤
≤ ≤
≥
≥ ≥ ≥
≦
≦ ≦ ≦
≧
≧ ≧ ≧
≨
≨ ≨
≩
≩ ≩
≪
≪ ≪ ≪
≫
≫ ≫ ≫
≬
≬ ≬
≭
≭
≮
≮ ≮ ≮
≯
≯ ≯ ≯
≰
≰ ≰ ≰
≱
≱ ≱ ≱
≲
≲ ≲ ≲
≳
≳ ≳ ≳
≴
≴ ≴
≵
≵ ≵
≶
≶ ≶ ≶
≷
≷ ≷ ≷
≸
≸ ≸
≹
≹ ≹
≺
≺ ≺ ≺
≻
≻ ≻ ≻
≼
≼ ≼ ≼
≽
≽ ≽ ≽
≾
≾ ≾ ≾
≿
≿ ≿ ≿
⊀
⊀ ⊀ ⊀
⊁
⊁ ⊁ ⊁
⊂
⊂ ⊂
⊃
⊃ ⊃ ⊃
⊄
⊄
⊅
⊅
⊆
⊆ ⊆ ⊆
⊇
⊇ ⊇ ⊇
⊈
⊈ ⊈ ⊈
⊉
⊉ ⊉ ⊉
⊊
⊊ ⊊
⊋
⊋ ⊋
⊍
⊍
⊎
⊎ ⊎
⊏
⊏ ⊏ ⊏
⊐
⊐ ⊐ ⊐
⊑
⊑ ⊑ ⊑
⊒
⊒ ⊒ ⊒
⊓
⊓ ⊓
⊔
⊔ ⊔
⊕
⊕ ⊕
⊖
⊖ ⊖
⊗
⊗ ⊗
⊘
⊘
⊙
⊙ ⊙
⊚
⊚ ⊚
⊛
⊛ ⊛
⊝
⊝ ⊝
⊞
⊞ ⊞
⊟
⊟ ⊟
⊠
⊠ ⊠
⊡
⊡ ⊡
⊢
⊢ ⊢
⊣
⊣ ⊣
⊤
⊤ ⊤
⊥
⊥ ⊥ ⊥ ⊥
⊧
⊧
⊨
⊨ ⊨
⊩
⊩
⊪
⊪
⊫
⊫
⊬
⊬
⊭
⊭
⊮
⊮
⊯
⊯
⊰
⊰
⊲
⊲ ⊲ ⊲
⊳
⊳ ⊳ ⊳
⊴
⊴ ⊴ ⊴
⊵
⊵ ⊵ ⊵
⊶
⊶
⊷
⊷
⊸
⊸ ⊸
⊹
⊹
⊺
⊺ ⊺
⊻
⊻
⊽
⊽
⊾
⊾
⊿
⊿
⋀
⋀ ⋀ ⋀
⋁
⋁ ⋁ ⋁
⋂
⋂ ⋂ ⋂
⋃
⋃ ⋃ ⋃
⋄
⋄ ⋄ ⋄
⋅
⋅
⋆
⋆ ⋆
⋇
⋇ ⋇
⋈
⋈
⋉
⋉
⋊
⋊
⋋
⋋ ⋋
⋌
⋌ ⋌
⋍
⋍ ⋍
⋎
⋎ ⋎
⋏
⋏ ⋏
⋐
⋐ ⋐
⋑
⋑ ⋑
⋒
⋒
⋓
⋓
⋔
⋔ ⋔
⋕
⋕
⋖
⋖ ⋖
⋗
⋗ ⋗
⋘
⋘
⋙
⋙ ⋙
⋚
⋚ ⋚ ⋚
⋛
⋛ ⋛ ⋛
⋞
⋞ ⋞
⋟
⋟ ⋟
⋠
⋠ ⋠
⋡
⋡ ⋡
⋢
⋢ ⋢
⋣
⋣ ⋣
⋦
⋦
⋧
⋧
⋨
⋨ ⋨
⋩
⋩ ⋩
⋪
⋪ ⋪ ⋪
⋫
⋫ ⋫ ⋫
⋬
⋬ ⋬ ⋬
⋭
⋭ ⋭ ⋭
⋮
⋮
⋯
⋯
⋰
⋰
⋱
⋱
⋲
⋲
⋳
⋳
⋴
⋴
⋵
⋵
⋶
⋶
⋷
⋷
⋹
⋹
⋺
⋺
⋻
⋻
⋼
⋼
⋽
⋽
⋾
⋾
⌅
⌅ ⌅
⌆
⌆ ⌆
⌈
⌈ ⌈
⌉
⌉ ⌉
⌊
⌊ ⌊
⌋
⌋ ⌋
⌌
⌌
⌍
⌍
⌎
⌎
⌏
⌏
⌐
⌐
⌒
⌒
⌓
⌓
⌕
⌕
⌖
⌖
⌜
⌜ ⌜
⌝
⌝ ⌝
⌞
⌞ ⌞
⌟
⌟ ⌟
⌢
⌢ ⌢
⌣
⌣ ⌣
⌭
⌭
⌮
⌮
⌶
⌶
⌽
⌽
⌿
⌿
⍼
⍼
⎰
⎰ ⎰
⎱
⎱ ⎱
⎴
⎴ ⎴
⎵
⎵ ⎵
⎶
⎶
⏜
⏜
⏝
⏝
⏞
⏞
⏟
⏟
⏢
⏢
⏧
⏧
␣
␣
Ⓢ
Ⓢ Ⓢ
─
─ ─
│
│
┌
┌
┐
┐
└
└
┘
┘
├
├
┤
┤
┬
┬
┴
┴
┼
┼
═
═
║
║
╒
╒
╓
╓
╔
╔
╕
╕
╖
╖
╗
╗
╘
╘
╙
╙
╚
╚
╛
╛
╜
╜
╝
╝
╞
╞
╟
╟
╠
╠
╡
╡
╢
╢
╣
╣
╤
╤
╥
╥
╦
╦
╧
╧
╨
╨
╩
╩
╪
╪
╫
╫
╬
╬
▀
▀
▄
▄
█
█
░
░
▒
▒
▓
▓
□
□ □ □
▪
▪ ▪ ▪ ▪
▫
▫
▭
▭
▮
▮
▱
▱
△
△ △
▴
▴ ▴
▵
▵ ▵
▸
▸ ▸
▹
▹ ▹
▽
▽ ▽
▾
▾ ▾
▿
▿ ▿
◂
◂ ◂
◃
◃ ◃
◊
◊ ◊
○
○
◬
◬
◯
◯ ◯
◸
◸
◹
◹
◺
◺
◻
◻
◼
◼
★
★ ★
☆
☆
☎
☎
♀
♀
♂
♂
♠
♠ ♠
♣
♣ ♣
♥
♥ ♥
♦
♦ ♦
♪
♪
♭
♭
♮
♮ ♮
♯
♯
✓
✓ ✓
✗
✗
✠
✠ ✠
✶
✶
❘
❘
❲
❲
❳
❳
⟦
⟦ ⟦
⟧
⟧ ⟧
⟨
⟨ ⟨ ⟨
⟩
⟩ ⟩ ⟩
⟪
⟪
⟫
⟫
⟬
⟬
⟭
⟭
⟵
⟵ ⟵ ⟵
⟶
⟶ ⟶ ⟶
⟷
⟷ ⟷ ⟷
⟸
⟸ ⟸ ⟸
⟹
⟹ ⟹ ⟹
⟺
⟺ ⟺ ⟺
⟼
⟼ ⟼
⟿
⟿
⤂
⤂
⤃
⤃
⤄
⤄
⤅
⤅
⤌
⤌
⤍
⤍ ⤍
⤎
⤎
⤏
⤏ ⤏
⤐
⤐ ⤐
⤑
⤑
⤒
⤒
⤓
⤓
⤖
⤖
⤙
⤙
⤚
⤚
⤛
⤛
⤜
⤜
⤝
⤝
⤞
⤞
⤟
⤟
⤠
⤠
⤣
⤣
⤤
⤤
⤥
⤥ ⤥
⤦
⤦ ⤦
⤧
⤧
⤨
⤨ ⤨
⤩
⤩ ⤩
⤪
⤪
⤳
⤳
⤵
⤵
⤶
⤶
⤷
⤷
⤸
⤸
⤹
⤹
⤼
⤼
⤽
⤽
⥅
⥅
⥈
⥈
⥉
⥉
⥊
⥊
⥋
⥋
⥎
⥎
⥏
⥏
⥐
⥐
⥑
⥑
⥒
⥒
⥓
⥓
⥔
⥔
⥕
⥕
⥖
⥖
⥗
⥗
⥘
⥘
⥙
⥙
⥚
⥚
⥛
⥛
⥜
⥜
⥝
⥝
⥞
⥞
⥟
⥟
⥠
⥠
⥡
⥡
⥢
⥢
⥣
⥣
⥤
⥤
⥥
⥥
⥦
⥦
⥧
⥧
⥨
⥨
⥩
⥩
⥪
⥪
⥫
⥫
⥬
⥬
⥭
⥭
⥮
⥮ ⥮
⥯
⥯ ⥯
⥰
⥰
⥱
⥱
⥲
⥲
⥳
⥳
⥴
⥴
⥵
⥵
⥶
⥶
⥸
⥸
⥹
⥹
⥻
⥻
⥼
⥼
⥽
⥽
⥾
⥾
⥿
⥿
⦅
⦅
⦆
⦆
⦋
⦋
⦌
⦌
⦍
⦍
⦎
⦎
⦏
⦏
⦐
⦐
⦑
⦑
⦒

Not fully, pls track the link for fully document.

answered Jan 19, 2017 at 15:24

What is the difference between htmlentities and htmlspecialchars in php?

0

Not the answer you're looking for? Browse other questions tagged php or ask your own question.

What is the use of Htmlspecialchars in PHP?

The htmlspecialchars() function converts some predefined characters to HTML entities.

What is the function of HTML entities?

The htmlentities() function converts characters to HTML entities. Tip: To convert HTML entities back to characters, use the html_entity_decode() function. Tip: Use the get_html_translation_table() function to return the translation table used by htmlentities().

When should you use the Htmlspecialchars function?

The htmlspecialchars() function is used to converts special characters ( e.g. & (ampersand), " (double quote), ' (single quote), < (less than), > (greater than)) to HTML entities ( i.e. & (ampersand) becomes &, ' (single quote) becomes ', < (less than) becomes < (greater than) becomes > ).

What does Htmlspecialchars return?

The htmlspecialchars() function returns the converted string.