(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
�������µij��� (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������ŷԪ���ţ�����ͷ�������ĸ�� Latin-1(ISO-8859-1) ��ȱʧ�� |
UTF-8 | ASCII ���ݵĶ��ֽ� 8 λ Unicode�� | |
cp866 | ibm866, 866 | DOS ���е���������롣���ַ����� 4.3.2 �汾�еõ�֧�֡� |
cp1251 | Windows-1251, win-1251, 1251 | Windows ���е���������롣���ַ����� 4.3.2 �汾�еõ�֧�֡� |
cp1252 | Windows-1252, 1252 | Windows ���е���ŷ���롣 |
KOI8-R | koi8-ru, koi8r | ������ַ����� 4.3.2 �汾�еõ�֧�֡� |
BIG5 | 950 | �������ģ���Ҫ�����й�̨��ʡ�� |
GB2312 | 936 | �������ģ��й����ұ��ַ����� |
BIG5-HKSCS | �������ģ����������չ�� 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) "'" // ... }