라이브러리
[PHP] iconv_mime_decode_headers - 여러 MIME 헤더 필드를 한 번에 디코딩합니다.
iconv_mime_decode_headers 함수
PHP의 `iconv_mime_decode_headers` 함수는 이메일 헤더의 인코딩을 해독하는 데 사용됩니다. 이 함수는 `iconv_mime_decode` 함수와 유사하지만, 이 함수는 이메일 헤더의 여러 줄을 처리할 수 있습니다.
함수 서식
`string iconv_mime_decode_headers ( string $headers [, int $options [, string $encoding ]])`
함수 매개변수
- `$headers`: 이메일 헤더의 문자열입니다. 여러 줄의 헤더를 처리하려면 ` ` 또는 ` `로 구분된 문자열을 사용하세요.
- `$options`: 옵션입니다. 기본값은 `0`입니다. 가능한 옵션은 다음과 같습니다.
+ `ICV_ASSUME8BIT`: 8비트 인코딩을 기본으로 가정합니다.
+ `ICV_NO_DECODE`: 인코딩을 해독하지 않습니다.
+ `ICV_USE_INTERNATIONAL`: 국제 문자를 지원합니다.
- `$encoding`: 인코딩을 사용할 문자열입니다. 기본값은 `NULL`입니다.
함수 반환
이 함수는 해독된 이메일 헤더의 문자열을 반환합니다.
예제
#hostingforum.kr
php
$headers = "From: John Doe
";
$headers .= "Subject: =?UTF-8?B?SGVsbG8gd29ybGQh?=
";
$headers .= "Content-Type: text/plain; charset=UTF-8
";
$decodedHeaders = iconv_mime_decode_headers($headers);
echo $decodedHeaders;
이 예제에서는 이메일 헤더의 인코딩을 해독하고, 해독된 헤더를 출력합니다. 출력 결과는 다음과 같습니다.
#hostingforum.kr
From: John Doe
Subject: Hello world!
Content-Type: text/plain; charset=UTF-8
주의
`iconv_mime_decode_headers` 함수는 이메일 헤더의 인코딩을 해독하는 데 사용됩니다. 이 함수는 이메일 헤더의 여러 줄을 처리할 수 있지만, 이 함수는 이메일 헤더의 유효성을 검사하지 않습니다. 이메일 헤더의 유효성을 검사하려면 `imap_rfc822_parse_headers` 함수를 사용하세요.
#hostingforum.kr
php
$headers = "From: John Doe
";
$headers .= "Subject: =?UTF-8?B?SGVsbG8gd29ybGQh?=
";
$headers .= "Content-Type: text/plain; charset=UTF-8
";
$decodedHeaders = iconv_mime_decode_headers($headers);
$imapHeaders = imap_rfc822_parse_headers($decodedHeaders);
echo $imapHeaders->subject;
이 예제에서는 이메일 헤더의 인코딩을 해독하고, 해독된 헤더를 `imap_rfc822_parse_headers` 함수로 전달하여 이메일 헤더의 유효성을 검사합니다. 출력 결과는 다음과 같습니다.
#hostingforum.kr
Hello world!
-
- 나우호스팅 @pcs8404
-
호스팅포럼 화이팅!
댓글목록
등록된 댓글이 없습니다.