
- PHP 7 Tutorial
- PHP 7 - Home
- PHP 7 - Introduction
- PHP 7 - Performance
- PHP 7 - Environment Setup
- PHP 7 - Scalar Type Declarations
- PHP 7 - Return Type Declarations
- PHP 7 - Null Coalescing Operator
- PHP 7 - Spaceship Operator
- PHP 7 - Constant Arrays
- PHP 7 - Anonymous Classes
- PHP 7 - Closure::call()
- PHP 7 - Filtered unserialize()
- PHP 7 - IntlChar
- PHP 7 - CSPRNG
- PHP 7 - Expectations
- PHP 7 - use Statement
- PHP 7 - Error Handling
- PHP 7 - Integer Division
- PHP 7 - Session Options
- PHP 7 - Deprecated Features
- PHP 7 - Removed Extensions & SAPIs
- PHP 7 Useful Resources
- PHP 7 - Quick Guide
- PHP 7 - Useful Resources
- PHP 7 - Discussion
PHP – Encode string for MIME header using mb_encode_mimeheader()
In PHP, mb_encode_mimeheader() function is used to encode a string for MIME (Multipurpose Internet Mail Extensions) header. It encodes a given string by the MIME header encoding scheme.
Syntax
string mb_encode_mimeheader(str $string, str $charset, str $transfer_encoding, str $newLine, int $indent)
Parameters
The mb_encode_mimeheader() function accepts five parameters −
$string − This parameter is used to encode the string. Its encoding should be the same as mb_internal_encoding()
$charset − This parameter specifies the character set name in which the string is represented.
$transfer_encoding − This parameter specifies the scheme of MIME encoding. It should be base64 (B) or Quoted-printable (Q). If not given, then it falls back to base64 (B).
$newLine − This parameter specifies the end-of-line (EOL) marker with which mb_encode_mimeheader() performs line-folding.
$indent − It is used for the indentation of the first line.
Return Values
It returns a converted version of the string that is represented in ASCII.
Example 1
<?php $name = "Online tutorials"; $mbox = "nru"; $doma = "gtin.thu"; $addr = mb_encode_mimeheader($name,"UTF-7","Q")." <".$mbox."@".$doma.">"; echo $addr; ?>
Output
Online tutorials
Example 2
<?php $string = "\xe2\x86\x92"; mb_internal_encoding( "UTF-8"); echo mb_encode_mimeheader($string, 'UTF-8'); ?>
Output
=?UTF-8?B?4oaS?=
- Related Articles
- Encode and decode MIME quoted-printable data using Python
- PHP – Compose a MIME header field using iconv_mime_encode() function
- Encode string array values in Numpy
- PHP – Decode multiple MIME header fields at once using iconv_mime_decode_headers()
- How to encode the string in android?
- How to encode a string in JavaScript?
- Encode String with Shortest Length in C++
- PHP – How to decode a MIME header field using iconv_mime_decode() function?
- Encode and decode uuencode files using Python
- Encode Number in C++
- How to URL encode a string (NSString) in iPhone?
- How to encode a URL using JavaScript function?
- Encode and decode binhex4 files using Python (binhex)
- Encode and decode XDR data using Python xdrlib
- Understanding base64 encode in MySQL?
