get_html_translation_table() function PHP

get_html_translation_table() function berguna untuk menampilkan daftar character entity beserta perubahannya karena penggunaan htmlspecialchars() dan htmlentities() function.

Syntax

array get_html_translation_table(int $table, int $flags, string $encoding)

Parameter

Parameter Penjelasan
table Parameter ini pilihan. Menentukan daftar character entity beserta perubahannya yang ingin ditampikan berdasarkan function yang digunakan.

  • HTML_ENTITIES (Default)
  • HTML_SPECIALCHARS
flags Parameter ini pilihan. Menentukan daftar character entity beserta perubahannya yang ingin ditampikan berdasarkan proses yang digunakan.

  • ENT_COMPAT (Default). Hanya mengubah double quote ["]
  • ENT_QUOTES. Mengubah single ['] dan double quote ["]
  • ENT_NOQUOTES. Tidak mengubah kedua jenis quote (single dan double quote)
  • ENT_HTML401 (Default). Code diproses sebagai HTML 4.01
  • ENT_HTML5. Code diproses sebagai HTML 5
  • ENT_XML1. Code diproses sebagai XML 1
  • ENT_XHTML. Code diproses sebagai XHTML
encoding Parameter ini pilihan. Menentukan daftar character entity beserta perubahannya yang ingin ditampikan berdasarkan character set yang digunakan.

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

Catatan

get_html_translation_table() function menghasilkan sebuah array yang berisi daftar character entity pada key dan nama entity pada value.

Contoh

Berikut ini adalah contoh penggunaan get_html_translation_table() function:

Code PHP 1:

<?php
$a = get_html_translation_table(HTML_SPECIALCHARS);
$b = get_html_translation_table(HTML_ENTITIES);

print_r($a);
print_r($b);
?>

Hasil running code di atas bila dilihat melalui page source browser akan tampak sebagai berikut ini:

Array
(
    ["] => &quot;
    [&] => &amp;
    [<] => &lt;
    [>] => &gt;
)
Array
(
    ["] => &quot;
    [&] => &amp;
    [<] => &lt;
    [>] => &gt;
    [ ] => &nbsp;
    [¡] => &iexcl;
    [¢] => &cent;
    [£] => &pound;
    [¤] => &curren;
    [¥] => &yen;
    [¦] => &brvbar;
    [§] => &sect;
    [¨] => &uml;
    [©] => &copy;
    [ª] => &ordf;
    [«] => &laquo;
    [¬] => &not;
    [­] => &shy;
    [®] => &reg;
    [¯] => &macr;
    [°] => &deg;
    [±] => &plusmn;
    [²] => &sup2;
    [³] => &sup3;
    [´] => &acute;
    [µ] => &micro;
    [¶] => &para;
    [·] => &middot;
    [¸] => &cedil;
    [¹] => &sup1;
    [º] => &ordm;
    [»] => &raquo;
    [¼] => &frac14;
    [½] => &frac12;
    [¾] => &frac34;
    [¿] => &iquest;
    [À] => &Agrave;
    [Á] => &Aacute;
    [Â] => &Acirc;
    [Ã] => &Atilde;
    [Ä] => &Auml;
    [Å] => &Aring;
    [Æ] => &AElig;
    [Ç] => &Ccedil;
    [È] => &Egrave;
    [É] => &Eacute;
    [Ê] => &Ecirc;
    [Ë] => &Euml;
    [Ì] => &Igrave;
    [Í] => &Iacute;
    [Î] => &Icirc;
    [Ï] => &Iuml;
    [Ð] => &ETH;
    [Ñ] => &Ntilde;
    [Ò] => &Ograve;
    [Ó] => &Oacute;
    [Ô] => &Ocirc;
    [Õ] => &Otilde;
    [Ö] => &Ouml;
    [×] => &times;
    [Ø] => &Oslash;
    [Ù] => &Ugrave;
    [Ú] => &Uacute;
    [Û] => &Ucirc;
    [Ü] => &Uuml;
    [Ý] => &Yacute;
    [Þ] => &THORN;
    [ß] => &szlig;
    [à] => &agrave;
    [á] => &aacute;
    [â] => &acirc;
    [ã] => &atilde;
    [ä] => &auml;
    [å] => &aring;
    [æ] => &aelig;
    [ç] => &ccedil;
    [è] => &egrave;
    [é] => &eacute;
    [ê] => &ecirc;
    [ë] => &euml;
    [ì] => &igrave;
    [í] => &iacute;
    [î] => &icirc;
    [ï] => &iuml;
    [ð] => &eth;
    [ñ] => &ntilde;
    [ò] => &ograve;
    [ó] => &oacute;
    [ô] => &ocirc;
    [õ] => &otilde;
    [ö] => &ouml;
    [÷] => &divide;
    [ø] => &oslash;
    [ù] => &ugrave;
    [ú] => &uacute;
    [û] => &ucirc;
    [ü] => &uuml;
    [ý] => &yacute;
    [þ] => &thorn;
    [ÿ] => &yuml;
    [Œ] => &OElig;
    [œ] => &oelig;
    [Š] => &Scaron;
    [š] => &scaron;
    [Ÿ] => &Yuml;
    [ƒ] => &fnof;
    [ˆ] => &circ;
    [˜] => &tilde;
    [Α] => &Alpha;
    [Β] => &Beta;
    [Γ] => &Gamma;
    [Δ] => &Delta;
    [Ε] => &Epsilon;
    [Ζ] => &Zeta;
    [Η] => &Eta;
    [Θ] => &Theta;
    [Ι] => &Iota;
    [Κ] => &Kappa;
    [Λ] => &Lambda;
    [Μ] => &Mu;
    [Ν] => &Nu;
    [Ξ] => &Xi;
    [Ο] => &Omicron;
    [Π] => &Pi;
    [Ρ] => &Rho;
    [Σ] => &Sigma;
    [Τ] => &Tau;
    [Υ] => &Upsilon;
    [Φ] => &Phi;
    [Χ] => &Chi;
    [Ψ] => &Psi;
    [Ω] => &Omega;
    [α] => &alpha;
    [β] => &beta;
    [γ] => &gamma;
    [δ] => &delta;
    [ε] => &epsilon;
    [ζ] => &zeta;
    [η] => &eta;
    [θ] => &theta;
    [ι] => &iota;
    [κ] => &kappa;
    [λ] => &lambda;
    [μ] => &mu;
    [ν] => &nu;
    [ξ] => &xi;
    [ο] => &omicron;
    [π] => &pi;
    [ρ] => &rho;
    [ς] => &sigmaf;
    [σ] => &sigma;
    [τ] => &tau;
    [υ] => &upsilon;
    [φ] => &phi;
    [χ] => &chi;
    [ψ] => &psi;
    [ω] => &omega;
    [ϑ] => &thetasym;
    [ϒ] => &upsih;
    [ϖ] => &piv;
    [ ] => &ensp;
    [ ] => &emsp;
    [ ] => &thinsp;
    [‌] => &zwnj;
    [‍] => &zwj;
    [‎] => &lrm;
    [‏] => &rlm;
    [–] => &ndash;
    [—] => &mdash;
    [‘] => &lsquo;
    [’] => &rsquo;
    [‚] => &sbquo;
    [“] => &ldquo;
    [”] => &rdquo;
    [„] => &bdquo;
    [†] => &dagger;
    [‡] => &Dagger;
    [•] => &bull;
    […] => &hellip;
    [‰] => &permil;
    [′] => &prime;
    [″] => &Prime;
    [‹] => &lsaquo;
    [›] => &rsaquo;
    [‾] => &oline;
    [⁄] => &frasl;
    [€] => &euro;
    [ℑ] => &image;
    [℘] => &weierp;
    [ℜ] => &real;
    [™] => &trade;
    [ℵ] => &alefsym;
    [←] => &larr;
    [↑] => &uarr;
    [→] => &rarr;
    [↓] => &darr;
    [↔] => &harr;
    [↵] => &crarr;
    [⇐] => &lArr;
    [⇑] => &uArr;
    [⇒] => &rArr;
    [⇓] => &dArr;
    [⇔] => &hArr;
    [∀] => &forall;
    [∂] => &part;
    [∃] => &exist;
    [∅] => &empty;
    [∇] => &nabla;
    [∈] => &isin;
    [∉] => &notin;
    [∋] => &ni;
    [∏] => &prod;
    [∑] => &sum;
    [−] => &minus;
    [∗] => &lowast;
    [√] => &radic;
    [∝] => &prop;
    [∞] => &infin;
    [∠] => &ang;
    [∧] => &and;
    [∨] => &or;
    [∩] => &cap;
    [∪] => &cup;
    [∫] => &int;
    [∴] => &there4;
    [∼] => &sim;
    [≅] => &cong;
    [≈] => &asymp;
    [≠] => &ne;
    [≡] => &equiv;
    [≤] => &le;
    [≥] => &ge;
    [⊂] => &sub;
    [⊃] => &sup;
    [⊄] => &nsub;
    [⊆] => &sube;
    [⊇] => &supe;
    [⊕] => &oplus;
    [⊗] => &otimes;
    [⊥] => &perp;
    [⋅] => &sdot;
    [⌈] => &lceil;
    [⌉] => &rceil;
    [⌊] => &lfloor;
    [⌋] => &rfloor;
    [〈] => &lang;
    [〉] => &rang;
    [◊] => &loz;
    [♠] => &spades;
    [♣] => &clubs;
    [♥] => &hearts;
    [♦] => &diams;
)

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>