php8.5
Home/ Manual/ iconv / functions/ iconv_mime_decode

iconv_mime_decode

PHP function Edit on GitHub ✎

(PHP 5, PHP 7, PHP 8)

Decodes a MIME header field

Description

iconv_mime_decode(string $string, int $mode = 0, string|null $encoding = null): string|false

Decodes a MIME header field.

Parameters

string

The encoded header, as a string.

mode

mode determines the behaviour in the event iconv_mime_decode() encounters a malformed MIME header field. You can specify any combination of the following bitmasks.

ValueConstantDescription
1ICONV_MIME_DECODE_STRICTIf set, the given header is decoded in full conformance with the standards defined in RFC2047. This option is disabled by default because there are a lot of broken mail user agents that don't follow the specification and don't produce correct MIME headers.
2ICONV_MIME_DECODE_CONTINUE_ON_ERRORIf set, iconv_mime_decode_headers() attempts to ignore any grammatical errors and continue to process a given header.
encoding

The optional encoding parameter specifies the character set to represent the result by. If omitted or null, iconv.internal_encoding will be used.

Return Values

Returns a decoded MIME field on success, or false if an error occurs during the decoding.

Changelog

VersionDescription
8.0.0encoding is nullable now.

Examples

iconv_mime_decode() example

php
<?php
// This yields "Subject: Prüfung Prüfung"
echo iconv_mime_decode("Subject: =?UTF-8?B?UHLDvGZ1bmcgUHLDvGZ1bmc=?=",
                       0, "ISO-8859-1");
?>

See Also

Source: reference/iconv/functions/iconv-mime-decode.xml · from the official PHP manual (php/doc-en)