本文整理匯總了PHP中Part::getHeader方法的典型用法代碼示例。如果您正苦於以下問題:PHP Part::getHeader方法的具體用法?PHP Part::getHeader怎麽用?PHP Part::getHeader使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Part
的用法示例。
在下文中一共展示了Part::getHeader方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: testEmailBase64
/**
* Test a email document with base64 encoding
*/
public function testEmailBase64()
{
$content = file_get_contents(__DIR__ . '/../../data/email_base64.txt');
$part = new Part($content);
self::assertTrue($part->isMultiPart());
$this->setExpectedException('\\LogicException', "MultiPart content, there aren't body");
$part->getBody();
self::assertEquals('This is thé subject', $part->getHeader('Subject'));
/** @var Part[] $parts */
$parts = $part->getParts();
self::assertEquals('This is the content', $parts[0]->getBody());
self::assertEquals('This is the côntént', $parts[1]->getBody());
}
示例2: decodeContent
/**
* Decodes the content of a Mime part.
*
* @param \BeSimple\SoapCommon\Mime\Part $part Part to add content
* @param string $content Content to decode
*
* @return null
*/
private static function decodeContent(Part $part, $content)
{
$encoding = strtolower($part->getHeader('Content-Transfer-Encoding'));
$charset = strtolower($part->getHeader('Content-Type', 'charset'));
if ($encoding == Part::ENCODING_BASE64) {
$content = base64_decode($content);
} elseif ($encoding == Part::ENCODING_QUOTED_PRINTABLE) {
$content = quoted_printable_decode($content);
}
if ($charset != 'utf-8') {
$content = iconv($charset, 'utf-8', $content);
}
$part->setContent($content);
}