本文整理汇总了PHP中Zend\Mail\Headers::addHeaders方法的典型用法代码示例。如果您正苦于以下问题:PHP Headers::addHeaders方法的具体用法?PHP Headers::addHeaders怎么用?PHP Headers::addHeaders使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend\Mail\Headers
的用法示例。
在下文中一共展示了Headers::addHeaders方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
* Public constructor
*
* Part supports different sources for content. The possible params are:
* - handler an instance of AbstractStorage for late fetch
* - id number of message for handler
* - raw raw content with header and body as string
* - headers headers as array (name => value) or string, if a content part is found it's used as toplines
* - noToplines ignore content found after headers in param 'headers'
* - content content as string
* - strict strictly parse raw content
*
* @param array $params full message with or without headers
* @throws Exception\InvalidArgumentException
*/
public function __construct(array $params)
{
if (isset($params['handler'])) {
if (!$params['handler'] instanceof AbstractStorage) {
throw new Exception\InvalidArgumentException('handler is not a valid mail handler');
}
if (!isset($params['id'])) {
throw new Exception\InvalidArgumentException('need a message id with a handler');
}
$this->mail = $params['handler'];
$this->messageNum = $params['id'];
}
$params['strict'] = isset($params['strict']) ? $params['strict'] : false;
if (isset($params['raw'])) {
Mime\Decode::splitMessage($params['raw'], $this->headers, $this->content, Mime\Mime::LINEEND, $params['strict']);
} elseif (isset($params['headers'])) {
if (is_array($params['headers'])) {
$this->headers = new Headers();
$this->headers->addHeaders($params['headers']);
} else {
if (empty($params['noToplines'])) {
Mime\Decode::splitMessage($params['headers'], $this->headers, $this->topLines);
} else {
$this->headers = Headers::fromString($params['headers']);
}
}
if (isset($params['content'])) {
$this->content = $params['content'];
}
}
}
示例2: testHeadersCanBeCastToArray
public function testHeadersCanBeCastToArray()
{
$headers = new Headers();
$headers->addHeaders(array('Foo' => 'bar', 'Baz' => 'baz'));
$this->assertEquals(array('Foo' => 'bar', 'Baz' => 'baz'), $headers->toArray());
}