(PHP 4, PHP 5, PHP 7)
get_html_translation_table — 锟斤拷锟斤拷使锟斤拷 htmlspecialchars() 锟斤拷 htmlentities() 锟斤拷锟阶拷锟斤拷锟�
$table
= HTML_SPECIALCHARS
[, int $flags
= ENT_COMPAT | ENT_HTML401
[, string $encoding
= 'UTF-8'
]]] ) : arrayget_html_translation_table() 锟斤拷锟斤拷锟斤拷 htmlspecialchars() 锟斤拷 htmlentities() 锟斤拷锟斤拷锟斤拷转锟斤拷锟斤拷
Note:
锟斤拷锟斤拷锟街凤拷锟斤拷锟斤拷使锟矫讹拷锟斤拷转锟斤拷锟斤拷式锟斤拷 锟斤拷锟界: " 锟斤拷锟皆憋拷转锟斤拷锟斤拷 ", " 锟斤拷锟斤拷 ". get_html_translation_table() 锟斤拷锟斤拷锟斤拷锟斤拷锟筋常锟矫的★拷
table
锟斤拷锟斤拷锟斤拷锟铰的筹拷锟斤拷 (HTML_ENTITIES
,
HTML_SPECIALCHARS
) 锟斤拷锟斤拷锟斤拷指锟斤拷锟斤拷锟斤拷要锟侥憋拷
flags
A bitmask of one or more of the following flags, which specify which quotes the table will contain as well as which document type the table is for. The default is ENT_COMPAT | ENT_HTML401.
Constant Name | Description |
---|---|
ENT_COMPAT |
Table will contain entities for double-quotes, but not for single-quotes. |
ENT_QUOTES |
Table will contain entities for both double and single quotes. |
ENT_NOQUOTES |
Table will neither contain entities for single quotes nor for double quotes. |
ENT_HTML401 |
Table for HTML 4.01. |
ENT_XML1 |
Table for XML 1. |
ENT_XHTML |
Table for XHTML. |
ENT_HTML5 |
Table for HTML 5. |
encoding
Encoding to use. If omitted, the default value for this argument is ISO-8859-1 in versions of PHP prior to 5.4.0, and UTF-8 from PHP 5.4.0 onwards.
支锟斤拷锟斤拷锟斤拷锟街凤拷锟斤拷锟斤拷
锟街凤拷锟斤拷 | 锟斤拷锟斤拷 | 锟斤拷锟斤拷 |
---|---|---|
ISO-8859-1 | ISO8859-1 | 锟斤拷欧锟斤拷Latin-1 |
ISO-8859-5 | ISO8859-5 | Little used cyrillic charset (Latin/Cyrillic). |
ISO-8859-15 | ISO8859-15 | 锟斤拷欧锟斤拷Latin-9锟斤拷锟斤拷锟斤拷欧元锟斤拷锟脚o拷锟斤拷锟斤拷头锟斤拷锟斤拷锟斤拷锟侥革拷锟� Latin-1(ISO-8859-1) 锟斤拷缺失锟斤拷 |
UTF-8 | ASCII 锟斤拷锟捷的讹拷锟街斤拷 8 位 Unicode锟斤拷 | |
cp866 | ibm866, 866 | DOS 锟斤拷锟叫碉拷锟斤拷锟斤拷锟斤拷锟斤拷搿o拷锟斤拷址锟斤拷锟斤拷锟� 4.3.2 锟芥本锟叫得碉拷支锟街★拷 |
cp1251 | Windows-1251, win-1251, 1251 | Windows 锟斤拷锟叫碉拷锟斤拷锟斤拷锟斤拷锟斤拷搿o拷锟斤拷址锟斤拷锟斤拷锟� 4.3.2 锟芥本锟叫得碉拷支锟街★拷 |
cp1252 | Windows-1252, 1252 | Windows 锟斤拷锟叫碉拷锟斤拷欧锟斤拷锟诫。 |
KOI8-R | koi8-ru, koi8r | 锟斤拷锟斤。锟斤拷锟街凤拷锟斤拷锟斤拷 4.3.2 锟芥本锟叫得碉拷支锟街★拷 |
BIG5 | 950 | 锟斤拷锟斤拷锟斤拷锟侥o拷锟斤拷要锟斤拷锟斤拷锟叫癸拷台锟斤拷省锟斤拷 |
GB2312 | 936 | 锟斤拷锟斤拷锟斤拷锟侥o拷锟叫癸拷锟斤拷锟揭憋拷准锟街凤拷锟斤拷锟斤拷 |
BIG5-HKSCS | 锟斤拷锟斤拷锟斤拷锟侥o拷锟斤拷锟斤拷锟斤拷锟斤拷锟秸癸拷锟� Big5 锟街凤拷锟斤拷锟斤拷 | |
Shift_JIS | SJIS, 932 | 锟斤拷锟斤拷 |
EUC-JP | EUCJP | 锟斤拷锟斤拷 |
MacRoman | Mac OS 使锟矫碉拷锟街凤拷锟斤拷锟斤拷 | |
'' | An empty string activates detection from script encoding (Zend multibyte), default_charset and current locale (see nl_langinfo() and setlocale()), in this order. Not recommended. |
Note: 锟斤拷锟斤拷锟街凤拷锟斤拷没锟斤拷锟较可★拷锟斤拷锟斤拷使锟斤拷默锟较憋拷锟诫并锟阶筹拷锟届常锟斤拷
锟斤拷转锟斤拷锟斤拷锟斤拷为一锟斤拷锟斤拷锟介返锟截★拷
锟芥本 | 说锟斤拷 |
---|---|
5.4.0 |
The default value for the encoding parameter was
changed to UTF-8.
|
5.4.0 |
The constants ENT_HTML401 , ENT_XML1 ,
ENT_XHTML and ENT_HTML5 were added.
|
5.3.4 |
The encoding parameter was added.
|
Example #1 Translation Table Example
<?php
var_dump(get_html_translation_table(HTML_ENTITIES, ENT_QUOTES | ENT_HTML5));
?>
锟斤拷锟斤拷锟斤拷锟教碉拷锟斤拷锟斤拷锟斤拷锟斤拷冢锟�
array(1510) { [" "]=> string(9) "
" ["!"]=> string(6) "!" ["""]=> string(6) """ ["#"]=> string(5) "#" ["$"]=> string(8) "$" ["%"]=> string(8) "%" ["&"]=> string(5) "&" ["'"]=> string(6) "'" // ... }