本文整理汇总了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);
}