(PHP 5, PHP 7)
iconv_mime_decode_headers — һ���Խ����� MIME ͷ�ֶ�
$encoded_headers
[, int $mode = 0
[, string $charset = ini_get("iconv.internal_encoding")
]] ) : arrayһ���Խ����� MIME ͷ�ֶΡ�
encoded_headers�������ͷ����һ���ַ�����
mode
mode ������ iconv_mime_decode_headers() �������� MIME ͷ�ֶ�ʱ����Ϊ��
�����ָ��Ϊ����λ�����������ϡ�
| ֵ | ���� | ���� |
|---|---|---|
| 1 | ICONV_MIME_DECODE_STRICT | ��������ˣ�������ͷ������ » RFC2047 ����ı���ȫһ�¡� ���ѡ��Ĭ�Ͻ��ã���Ϊ������������ʼ��û�������ѭ������������ȷ�� MIME ͷ�� |
| 2 | ICONV_MIME_DECODE_CONTINUE_ON_ERROR | ��������ˣ�iconv_mime_decode_headers() ���Ժ����κ������������ָ����ͷ�� |
charset
��ѡ���� charset ָ�����ַ�������ı��֡�
���ʡ���ˣ���ʹ��
iconv.internal_encoding��
�ɹ�ʱ���� encoded_headers ָ���� MIME ͷ�����������飬����ʱ���ִ����� FALSE��
����Ԫ�ص�ÿ������������ֶ�������Ӧ��Ԫ�ش���һ���ֶ�ֵ�� ����ж��ͬһ���Ƶ��ֶΣ� iconv_mime_decode_headers() �Զ������ǰ�����˳���ϳ��������������顣
Example #1 iconv_mime_decode_headers() ����
<?php
$headers_string = <<<EOF
Subject: =?UTF-8?B?UHLDvGZ1bmcgUHLDvGZ1bmc=?=
To: example@example.com
Date: Thu, 1 Jan 1970 00:00:00 +0000
Message-Id: <example@example.com>
Received: from localhost (localhost [127.0.0.1]) by localhost
with SMTP id example for <example@example.com>;
Thu, 1 Jan 1970 00:00:00 +0000 (UTC)
(envelope-from example-return-0000-example=example.com@example.com)
Received: (qmail 0 invoked by uid 65534); 1 Thu 2003 00:00:00 +0000
EOF;
$headers = iconv_mime_decode_headers($headers_string, 0, "ISO-8859-1");
print_r($headers);
?>
�������̻������
Array
(
[Subject] => Pr��fung Pr��fung
[To] => example@example.com
[Date] => Thu, 1 Jan 1970 00:00:00 +0000
[Message-Id] => <example@example.com>
[Received] => Array
(
[0] => from localhost (localhost [127.0.0.1]) by localhost with SMTP id example for <example@example.com>; Thu, 1 Jan 1970 00:00:00 +0000 (UTC) (envelope-from example-return-0000-example=example.com@example.com)
[1] => (qmail 0 invoked by uid 65534); 1 Thu 2003 00:00:00 +0000
)
)