tutorial pengembangan web terbaru
 

PHP get_html_translation_table() Function

<PHP String Reference

Contoh

Cetak tabel terjemahan yang digunakan oleh fungsi htmlspecialchars:

<?php
print_r (get_html_translation_table()); // HTML_SPECIALCHARS is default.
?>
Menjalankan contoh »

Definisi dan Penggunaan

The get_html_translation_table() mengembalikan fungsi tabel terjemahan yang digunakan oleh htmlentities() dan htmlspecialchars() fungsi.

Tip: Beberapa karakter dapat dikodekan beberapa cara. The get_html_translation_table() mengembalikan fungsi encoding paling umum.


Sintaksis

get_html_translation_table( function,flags,character-set )

Parameter Deskripsi
function Pilihan. Menentukan yang tabel terjemahan untuk kembali.

Kemungkinan nilai:

  • HTML_SPECIALCHARS - default. Menerjemahkan beberapa karakter yang perlu URL-encoding yang akan ditampilkan dengan benar pada halaman HTML
  • HTML_ENTITIES - Menerjemahkan semua karakter yang perlu URL-encoding yang akan ditampilkan dengan benar pada halaman HTML
flags Pilihan. Menentukan yang mengutip tabel akan berisi dan mana dokumen ketik tabel adalah untuk.

Gaya kutipan yang tersedia adalah:

  • ENT_COMPAT - default. Tabel berisi entitas untuk tanda kutip ganda, tanda kutip tidak tunggal
  • ENT_QUOTES - Tabel berisi entitas untuk tanda kutip ganda dan tunggal
  • ENT_NOQUOTES - Tabel tidak akan berisi entitas untuk tanda kutip ganda dan tunggal

bendera tambahan untuk menspesifikasikan doctype meja adalah untuk:

  • ENT_HTML401 - default. Tabel untuk HTML 4.01
  • ENT_HTML5 - Tabel untuk HTML 5
  • ENT_XML1 - Tabel untuk XML 1
  • ENT_XHTML - Tabel untuk XHTML
character-set Pilihan. Sebuah string yang menentukan karakter-diatur untuk menggunakan.

nilai yang diperbolehkan adalah:

  • UTF-8 - Default. ASCII kompatibel multi-byte 8-bit Unicode
  • ISO-8859-1 - Eropa Barat
  • ISO-8859-15 - Eropa Barat (menambahkan Euro tanda + huruf Perancis dan Finlandia hilang dalam ISO-8859-1)
  • cp866 - DOS khusus charset Cyrillic
  • CP1251 - Windows-spesifik charset Cyrillic
  • cp1252 - Jendela charset khusus untuk Eropa Barat
  • KOI8-R - Rusia
  • BIG5 - Cina Tradisional, terutama digunakan di Taiwan
  • GB2312 - Cina Sederhana, standar nasional set karakter
  • BIG5-HKSCS - Big5 dengan ekstensi Hong Kong
  • Shift_JIS - Jepang
  • EUC-JP - Jepang
  • MacRoman - Karakter-set yang digunakan oleh Mac OS

Note: tidak dikenal karakter-set akan diabaikan dan diganti dengan ISO-8859-1 versi sebelum PHP 5.4. Sebagai PHP 5.4, akan diabaikan sebuah diganti dengan UTF-8.

Rincian teknis

Kembali Nilai: Mengembalikan tabel terjemahan sebagai array, dengan karakter asli sebagai kunci dan entitas sebagai nilai-nilai
PHP Versi: 4+
changelog: Nilai default untuk parameter karakter-set diubah menjadi UTF-8 di PHP 5

Tambahan bendera untuk menspesifikasikan doctype meja adalah untuk; ENT_HTML401, ENT_HTML5, ENT_XML1 dan ENT_XHTML ditambahkan di PHP 5.4

Karakter-set parameter ditambahkan di PHP 5.3.4

Contoh lebih

Contoh

Tabel untuk HTML_SPECIALCHARS:

<?php
print_r (get_html_translation_table(HTML_SPECIALCHARS));
?>

Menampilkan karakter dan entitas nama:

Array
(
  ["] => &quot;
  [&] => &amp;
  [<] => &lt;
  [>] => &gt;
)



contoh 2

Tabel untuk HTML_ENTITIES:

<?php
print_r (get_html_translation_table(HTML_ENTITIES));
?>

Menampilkan karakter dan entitas nama:

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;
)


<PHP String Reference