get_html_translation_table

(PHP 4, PHP 5, PHP 7)

get_html_translation_table����ʹ�� htmlspecialchars() �� htmlentities() ���ת����

˵��

get_html_translation_table ([ int $table = HTML_SPECIALCHARS [, int $flags = ENT_COMPAT | ENT_HTML401 [, string $encoding = 'UTF-8' ]]] ) : array

get_html_translation_table() ������ htmlspecialchars() �� htmlentities() ������ת����

Note:

�����ַ�����ʹ�ö���ת����ʽ�� ���磺 " ���Ա�ת���� ", " ���� &#x22. 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.

Available flags constants
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_ENTITIESENT_QUOTES ENT_HTML5));
?>

�������̵���������ڣ�

array(1510) {
  ["
"]=>
  string(9) "&NewLine;"
  ["!"]=>
  string(6) "&excl;"
  ["""]=>
  string(6) "&quot;"
  ["#"]=>
  string(5) "&num;"
  ["$"]=>
  string(8) "&dollar;"
  ["%"]=>
  string(8) "&percnt;"
  ["&"]=>
  string(5) "&amp;"
  ["'"]=>
  string(6) "&apos;"
  // ...
}

�μ�