»¶Ó­Äú ±¾Õ¾µØÖ·:  

PHP get_html_translation_table() º¯Êý

PHP String ²Î¿¼ÊÖ²á PHP String ²Î¿¼ÊÖ²á

ʵÀý

Êä³ö htmlspecialchars º¯ÊýʹÓõķ­Òë±í£º

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

ÔËÐÐʵÀý ?

¶¨ÒåºÍÓ÷¨

get_html_translation_table() º¯Êý·µ»Ø htmlentities() ºÍ htmlspecialchars() º¯ÊýʹÓõķ­Òë±í¡£

Ìáʾ£ºÒ»Ð©×Ö·û¿ÉÒÔ°´ÕÕÈô¸ÉÖÖ·½Ê½½øÐбàÂë¡£get_html_translation_table() º¯Êý·µ»Ø×îÆÕͨµÄ±àÂë¡£


Óï·¨

get_html_translation_table(function,flags,character-set)

²ÎÊý ÃèÊö
function ¿ÉÑ¡¡£¹æ¶¨·µ»ØÄĸö·­Òë±í¡£

¿ÉÄܵÄÖµ£º

  • HTML_SPECIALCHARS - ĬÈÏ¡£·­ÒëijЩÐèÒª URL ±àÂëµÄ×Ö·û£¬ÒÔ±ãÕýÈ·µØÏÔʾÔÚ HTML Ò³ÃæÉÏ¡£
  • HTML_ENTITIES - ·­ÒëËùÓÐÐèÒª URL ±àÂëµÄ×Ö·û£¬ÒÔ±ãÕýÈ·µØÏÔʾÔÚ HTML Ò³ÃæÉÏ¡£
flags ¿ÉÑ¡¡£¹æ¶¨·­Òë±í½«°üº¬ÄÄÖÖÒýºÅÒÔ¼°·­Òë±íÓÃÓÚÄÄÖÖÎĵµÀàÐÍ¡£

¿ÉÓõÄÒýºÅÀàÐÍ£º

  • ENT_COMPAT - ĬÈÏ¡£·­Òë±í°üº¬Ë«ÒýºÅʵÌ壬²»°üº¬µ¥ÒýºÅʵÌå¡£
  • ENT_QUOTES - ·­Òë±í°üº¬Ë«ÒýºÅʵÌåºÍµ¥ÒýºÅʵÌå¡£
  • ENT_NOQUOTES - ·­Òë±í²»°üº¬Ë«ÒýºÅʵÌåºÍµ¥ÒýºÅʵÌå¡£

¹æ¶¨·­Òë±íÊÊÓõÄÎĵµÀàÐ͵ĸ½¼Ó flags£º

  • ENT_HTML401 - ĬÈÏ¡£HTML 4.01 µÄ·­Òë±í¡£
  • ENT_HTML5 - HTML 5 µÄ·­Òë±í¡£
  • ENT_XML1 - XML 1 µÄ·­Òë±í¡£
  • ENT_XHTML - XHTML µÄ·­Òë±í¡£
character-set ¿ÉÑ¡¡£Ò»¸ö¹æ¶¨ÁËҪʹÓõÄ×Ö·û¼¯µÄ×Ö·û´®¡£

ÔÊÐíµÄÖµ£º

  • UTF-8 - ĬÈÏ¡£ASCII ¼æÈݶà×Ö½ÚµÄ 8 λ Unicode
  • ISO-8859-1 - Î÷Å·
  • ISO-8859-15 - Î÷Å·£¨¼ÓÈëÅ·Ôª·ûºÅ + ISO-8859-1 ÖжªÊ§µÄ·¨ÓïºÍ·ÒÀ¼Óï×Öĸ£©
  • cp866 - DOS רÓà Cyrillic ×Ö·û¼¯
  • cp1251 - Windows רÓà Cyrillic ×Ö·û¼¯
  • cp1252 - Windows רÓÃÎ÷Å·×Ö·û¼¯
  • KOI8-R - ¶íÓï
  • BIG5 - ·±ÌåÖÐÎÄ£¬Ö÷ÒªÔŲ́ÍåʹÓÃ
  • GB2312 - ¼òÌåÖÐÎÄ£¬¹ú¼Ò±ê×¼×Ö·û¼¯
  • BIG5-HKSCS - ´øÏã¸ÛÀ©Õ¹µÄ Big5
  • Shift_JIS - ÈÕÓï
  • EUC-JP - ÈÕÓï
  • MacRoman - Mac ²Ù×÷ϵͳʹÓõÄ×Ö·û¼¯

×¢ÊÍ£ºÔÚ PHP 5.4 ֮ǰµÄ°æ±¾£¬ÎÞ·¨±»Ê¶±ðµÄ×Ö·û¼¯½«±»ºöÂÔ²¢ÓÉ ISO-8859-1 Ìæ´ú¡£×Ô PHP 5.4 Æð£¬ÎÞ·¨±»Ê¶±ðµÄ×Ö·û¼¯½«±»ºöÂÔ²¢ÓÉ UTF-8 Ìæ´ú¡£

¼¼Êõϸ½Ú

·µ»ØÖµ£º ÒÔÊý×éÐÎʽ·µ»Ø·­Òë±í£¬Ô­Ê¼×Ö·û×÷Ϊ¼üÃû£¬ÊµÌå×÷Ϊ¼üÖµ¡£
PHP °æ±¾£º 4+
¸üÐÂÈÕÖ¾£º ÔÚ PHP 5 ÖУ¬character-set ²ÎÊýµÄĬÈÏÖµ¸ÄΪ UTF-8¡£

ÔÚ PHP 5.4 ÖУ¬ÐÂÔöÁËÓÃÓڹ涨·­Òë±íÊÊÓõÄÎĵµÀàÐ͵ĸ½¼Ó flags£ºENT_HTML401¡¢ENT_HTML5¡¢ENT_XML1 ºÍ ENT_XHTML¡£

ÔÚ PHP 5.3.4 ÖУ¬ÐÂÔöÁË character-set ²ÎÊý¡£


¸ü¶àʵÀý

ʵÀý

HTML_SPECIALCHARS µÄ·­Òë±í£º

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

Displaying character and entity name:

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



ʵÀý 2

HTML_ENTITIES µÄ·­Òë±í£º

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

ÏÔʾ×Ö·û¼°Æä¶ÔÓ¦µÄʵÌåÃû³Æ£º

Array
(
  ["] => &quot;
  [&] => &amp;
  [<] => &lt;
  [>] => &gt;
  [ ] => &nbsp;
  [?] => &iexcl;
  [¡é] => &cent;
  [¡ê] => &pound;
  [¡è] => &curren;
  [£¤] => &yen;
  [|] => &brvbar;
  [¡ì] => &sect;
  [¡§] => &uml;
  [?] => &copy;
  [a] => &ordf;
  [?] => &laquo;
  [?] => &not;
  [-] => &shy;
  [?] => &reg;
  [¡¥] => &macr;
  [¡ã] => &deg;
  [¡À] => &plusmn;
  [2] => &sup2;
  [3] => &sup3;
  [¡ä] => &acute;
  [¦Ì] => &micro;
  [?] => &para;
  [¡¤] => &middot;
  [?] => &cedil;
  [1] => &sup1;
  [o] => &ordm;
  [?] => &raquo;
  [?] => &frac14;
  [?] => &frac12;
  [?] => &frac34;
  [?] => &iquest;
  [¨¤] => &Agrave;
  [¨¢] => &Aacute;
  [?] => &Acirc;
  [?] => &Atilde;
  [?] => &Auml;
  [?] => &Aring;
  [?] => &AElig;
  [?] => &Ccedil;
  [¨¨] => &Egrave;
  [¨¦] => &Eacute;
  [¨º] => &Ecirc;
  [?] => &Euml;
  [¨¬] => &Igrave;
  [¨ª] => &Iacute;
  [?] => &Icirc;
  [?] => &Iuml;
  [D] => &ETH;
  [?] => &Ntilde;
  [¨°] => &Ograve;
  [¨®] => &Oacute;
  [?] => &Ocirc;
  [?] => &Otilde;
  [?] => &Ouml;
  [¡Á] => &times;
  [?] => &Oslash;
  [¨´] => &Ugrave;
  [¨²] => &Uacute;
  [?] => &Ucirc;
  [¨¹] => &Uuml;
  [Y] => &Yacute;
  [T] => &THORN;
  [?] => &szlig;
  [¨¤] => &agrave;
  [¨¢] => &aacute;
  [a] => &acirc;
  [?] => &atilde;
  [?] => &auml;
  [?] => &aring;
  [?] => &aelig;
  [?] => &ccedil;
  [¨¨] => &egrave;
  [¨¦] => &eacute;
  [¨º] => &ecirc;
  [?] => &euml;
  [¨¬] => &igrave;
  [¨ª] => &iacute;
  [?] => &icirc;
  [?] => &iuml;
  [e] => &eth;
  [?] => &ntilde;
  [¨°] => &ograve;
  [¨®] => &oacute;
  [?] => &ocirc;
  [?] => &otilde;
  [?] => &ouml;
  [¡Â] => &divide;
  [?] => &oslash;
  [¨´] => &ugrave;
  [¨²] => &uacute;
  [?] => &ucirc;
  [¨¹] => &uuml;
  [y] => &yacute;
  [t] => &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;
  [¨C] => &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 ²Î¿¼ÊÖ²á PHP String ²Î¿¼ÊÖ²á
С¿âÌáʾ

ɨÃèÏ·½¶þάÂ룬·ÃÎÊÊÖ»ú°æ¡£