当前位置: 首页>>代码示例>>PHP>>正文


PHP Headers::addHeaders方法代码示例

本文整理汇总了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'];
         }
     }
 }
开发者ID:karnurik,项目名称:zf2-turtorial,代码行数:46,代码来源:Part.php

示例2: testHeadersCanBeCastToArray

 public function testHeadersCanBeCastToArray()
 {
     $headers = new Headers();
     $headers->addHeaders(array('Foo' => 'bar', 'Baz' => 'baz'));
     $this->assertEquals(array('Foo' => 'bar', 'Baz' => 'baz'), $headers->toArray());
 }
开发者ID:bradley-holt,项目名称:zf2,代码行数:6,代码来源:HeadersTest.php


注:本文中的Zend\Mail\Headers::addHeaders方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。