Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

PHP get_html_translation_table() Function

PHP get_html_translation_table() Function

PHP String Reference Manual PHP String Reference Manual

Example

Output the translation table used by the htmlspecialchars function:

Run Example »


Definition and Usage

The get_html_translation_table() function returns the htmlentities() and htmlspecialchars() translation table used by the function.

**Tip:** Some characters can be encoded in several ways. The get_html_translation_table() function returns the most common encoding.


Syntax

get_html_translation_table(

function,flags,character-set

)

Parameters Description
function Optional. Specifies which translation table to return.

Possible values:

  • HTML_SPECIALCHARS - Default. Translate certain characters that need URL encoding so they display correctly on HTML pages.
  • HTML_ENTITIES - Translate all characters that need URL encoding so they display correctly on HTML pages.
  • | | *flags* | Optional. Specifies which quotes the translation table will include and which document type the translation table is for.

    Available quote types:

    Additional flags specifying the document type the translation table applies to:

    | | *character-set* | Optional. A string specifying the character set to use.

    Allowed values:

    Note:Prior to PHP 5.4, an unrecognized character set would be ignored and replaced by ISO-8859-1. Since PHP 5.4, an unrecognized character set is ignored and replaced by UTF-8.

    |

    Technical Details

    Return Value: Returns the translation table as an array, with the original characters as keys and the entities as values.
    PHP Version: 4+
    Changelog: In PHP 5, thecharacter-set parameter's default value was changed to UTF-8.
     在 PHP 5.4 中,新增了用于Specifies翻译表适用的文档类型的附加 flags:ENT_HTML401、ENT_HTML5、ENT_XML1 和 ENT_XHTML。       
       
     在 PHP 5.3.4 中,新增了 *character-set* 参数。 |
    

    More examples

    Example

    Translation table for HTML_SPECIALCHARS:

    Displaying character and entity name:

    Array

    (

    ["] => "

    [&] => &

    [<] => <

    [>] => >

    )


    Example 2

    Translation table for HTML_ENTITIES:

    Display characters and their corresponding entity names:

    Array

    (

      ["] => "

      [&] => &

      [<] => <

      [>] => >

      [ ] =>  

      [¡] => ¡

      [¢] => ¢

      [£] => £

      [¤] => ¤

      [¥] => ¥

      [¦] => ¦

      [§] => §

      [¨] => ¨

      [©] => ©

      [ª] => ª

      [«] => «

      [¬] => ¬

      [­] => ­

      [®] => ®

      [¯] => ¯

      [°] => °

      [±] => ±

      [²] => ²

      [³] => ³

      [´] => ´

      [µ] => µ

      [¶] => ¶

      [·] => ·

      [¸] => ¸

      [¹] => ¹

      [º] => º

      [»] => »

      [¼] => ¼

      [½] => ½

      [¾] => ¾

      [¿] => ¿

      [À] => À

      [Á] => Á

      [Â] => Â

      [Ã] => Ã

      [Ä] => Ä

      [Å] => Å

      [Æ] => Æ

      [Ç] => Ç

      [È] => È

      [É] => É

      [Ê] => Ê

      [Ë] => Ë

      [Ì] => Ì

      [Í] => Í

      [Î] => Î

      [Ï] => Ï

      [Ð] => Ð

      [Ñ] => Ñ

      [Ò] => Ò

      [Ó] => Ó

      [Ô] => Ô

      [Õ] => Õ

      [Ö] => Ö

      [×] => ×

      [Ø] => Ø

      [Ù] => Ù

      [Ú] => Ú

      [Û] => Û

      [Ü] => Ü

      [Ý] => Ý

      [Þ] => Þ

      [ß] => ß

      [à] => à

      [á] => á

      [â] => â

      [ã] => ã

      [ä] => ä

      [å] => å

      [æ] => æ

      [ç] => ç

      [è] => è

      [é] => é

      [ê] => ê

      [ë] => ë

      [ì] => ì

      [í] => í

      [î] => î

      [ï] => ï

      [ð] => ð

      [ñ] => ñ

      [ò] => ò

      [ó] => ó

      [ô] => ô

      [õ] => õ

      [ö] => ö

      [÷] => ÷

      [ø] => ø

      [ù] => ù

      [ú] => ú

      [û] => û

      [ü] => ü

      [ý] => ý

      [þ] => þ

      [ÿ] => ÿ

      [Œ] => Œ

      [œ] => œ

      [Š] => Š

      [š] => š

      [Ÿ] => Ÿ

      [ƒ] => ƒ

      [ˆ] => ˆ

      [˜] => ˜

      [Α] => Α

      [Β] => Β

      [Γ] => Γ

      [Δ] => Δ

      [Ε] => Ε

      [Ζ] => Ζ

      [Η] => Η

      [Θ] => Θ

      [Ι] => Ι

      [Κ] => Κ

      [Λ] => Λ

      [Μ] => Μ

      [Ν] => Ν

      [Ξ] => Ξ

      [Ο] => Ο

      [Π] => Π

      [Ρ] => Ρ

      [Σ] => Σ

      [Τ] => Τ

      [Υ] => Υ

      [Φ] => Φ

      [Χ] => Χ

      [Ψ] => Ψ

      [Ω] => Ω

      [α] => α

      [β] => β

      [γ] => γ

      [δ] => δ

      [ε] => ε

      [ζ] => ζ

      [η] => η

      [θ] => θ

      [ι] => ι

      [κ] => κ

      [λ] => λ

      [μ] => μ

      [ν] => ν

      [ξ] => ξ

      [ο] => ο

      [π] => π

      [ρ] => ρ

      [ς] => ς

      [σ] => σ

      [τ] => τ

      [υ] => υ

      [φ] => φ

      [χ] => χ

      [ψ] => ψ

      [ω] => ω

      [ϑ] => ϑ

      [ϒ] => ϒ

      [ϖ] => ϖ

      [ ] =>  

      [ ] =>  

      [ ] =>  

      [‌] => ‌

      [‍] => ‍

      [‎] => ‎

      [‏] => ‏

      [–] => –

      [—] => —

      ['] => '

      ['] => '

      [‚] => ‚

      ["] => "

      ["] => "

      [„] => „

      [†] => †

      [‡] => ‡

      [•] => •

      [...] => ...

      [‰] => ‰

      [′] => ′

      [″] => ″

      [‹] => ‹

      [›] => ›

      [‾] => ‾

      [⁄] => ⁄

      [€] => €

      [ℑ] => ℑ

      [℘] => ℘

      [ℜ] => ℜ

      [™] => ™

      [ℵ] => ℵ

      [←] => ←

      [↑] => ↑

      [→] => →

      [↓] => ↓

      [↔] => ↔

      [↵] => ↵

      [⇐] => ⇐

      [⇑] => ⇑

      [⇒] => ⇒

      [⇓] => ⇓

      [⇔] => ⇔

      [∀] => ∀

      [∂] => ∂

      [∃] => ∃

      [∅] => ∅

      [∇] => ∇

      [∈] => ∈

      [∉] => ∉

      [∋] => ∋

      [∏] => ∏

      [∑] => ∑

      [−] => −

      [∗] => ∗

      [√] => √

      [∝] => ∝

      [∞] => ∞

      [∠] => ∠

      [∧] => ∧

      [∨] => ∨

      [∩] => ∩

      [∪] => ∪

      [∫] => ∫

      [∴] => ∴

      [∼] => ∼

      [≅] => ≅

      [≈] => ≈

      [≠] => ≠

      [≡] => ≡

      [≤] => ≤

      [≥] => ≥

      [⊂] => ⊂

      [⊃] => ⊃

      [⊄] => ⊄

      [⊆] => ⊆

      [⊇] => ⊇

      [⊕] => ⊕

      [⊗] => ⊗

      [⊥] => ⊥

      [⋅] => ⋅

      [⌈] => ⌈

      [⌉] => ⌉

      [⌊] => ⌊

      [⌋] => ⌋

      [〈] => ⟨

      [〉] => ⟩

      [◊] => ◊

      [♠] => ♠

      [♣] => ♣

      [♥] => ♥

      [♦] => ♦

    )


    PHP String Reference Manual PHP String Reference Manual