没有命名空间的类 yii yii\base yii\behaviors yii\caching yii\captcha yii\console yii\console\controllers yii\console\widgets yii\data yii\db yii\db\conditions yii\db\cubrid yii\db\cubrid\conditions yii\db\mssql yii\db\mssql\conditions yii\db\mysql yii\db\oci yii\db\oci\conditions yii\db\pgsql yii\db\sqlite yii\db\sqlite\conditions yii\di yii\filters yii\filters\auth yii\grid yii\helpers yii\i18n yii\log yii\mail yii\mutex yii\rbac yii\rest yii\test yii\validators yii\web yii\widgets

Class yii\web\HeaderCollection

继承yii\web\HeaderCollection » yii\base\BaseObject
实现ArrayAccess, Countable, IteratorAggregate, yii\base\Configurable
可用版本自2.0
源码 https://github.com/yiichina/yii2/blob/api/framework/web/HeaderCollection.php

HeaderCollection is used by yii\web\Response to maintain the currently registered HTTP headers.

公共属性

隐藏继承的属性

属性类型描述被定义在
$count integer The number of headers in the collection. yii\web\HeaderCollection
$iterator ArrayIterator An iterator for traversing the headers in the collection. yii\web\HeaderCollection

公共方法

隐藏继承的方法

方法描述被定义在
__call() Calls the named method which is not a class method. yii\base\BaseObject
__construct() Constructor. yii\base\BaseObject
__get() Returns the value of an object property. yii\base\BaseObject
__isset() Checks if a property is set, i.e. defined and not null. yii\base\BaseObject
__set() Sets value of an object property. yii\base\BaseObject
__unset() Sets an object property to null. yii\base\BaseObject
add() Adds a new header. yii\web\HeaderCollection
canGetProperty() Returns a value indicating whether a property can be read. yii\base\BaseObject
canSetProperty() Returns a value indicating whether a property can be set. yii\base\BaseObject
className() Returns the fully qualified name of this class. yii\base\BaseObject
count() Returns the number of headers in the collection. yii\web\HeaderCollection
fromArray() Populates the header collection from an array. yii\web\HeaderCollection
get() Returns the named header(s). yii\web\HeaderCollection
getCount() Returns the number of headers in the collection. yii\web\HeaderCollection
getIterator() Returns an iterator for traversing the headers in the collection. yii\web\HeaderCollection
has() Returns a value indicating whether the named header exists. yii\web\HeaderCollection
hasMethod() Returns a value indicating whether a method is defined. yii\base\BaseObject
hasProperty() Returns a value indicating whether a property is defined. yii\base\BaseObject
init() Initializes the object. yii\base\BaseObject
offsetExists() Returns whether there is a header with the specified name. yii\web\HeaderCollection
offsetGet() Returns the header with the specified name. yii\web\HeaderCollection
offsetSet() Adds the header to the collection. yii\web\HeaderCollection
offsetUnset() Removes the named header. yii\web\HeaderCollection
remove() Removes a header. yii\web\HeaderCollection
removeAll() Removes all headers. yii\web\HeaderCollection
set() Adds a new header. yii\web\HeaderCollection
setDefault() Sets a new header only if it does not exist yet. yii\web\HeaderCollection
toArray() Returns the collection as a PHP array. yii\web\HeaderCollection

属性详情

$count 公共 只读 属性

The number of headers in the collection.

public integer getCount ( )
$iterator 公共 只读 属性

An iterator for traversing the headers in the collection.

方法详情

add() 公共 方法

Adds a new header.

If there is already a header with the same name, the new one will be appended to it instead of replacing it.

public $this add($name, $value)
$name string

The name of the header

$value string

The value of the header

return $this

The collection object itself

count() 公共 方法

Returns the number of headers in the collection.

This method is required by the SPL Countable interface. It will be implicitly called when you use count($collection).

public integer count()
return integer

The number of headers in the collection.

fromArray() 公共 方法 (自版本 2.0.3 可用)

Populates the header collection from an array.

public void fromArray(array $array)
$array array

The headers to populate from

get() 公共 方法

Returns the named header(s).

public string|array get($name, $default null, $first true)
$name string

The name of the header to return

$default mixed

The value to return in case the named header does not exist

$first boolean

Whether to only return the first header of the specified name. If false, all headers of the specified name will be returned.

return string|array

The named header(s). If $first is true, a string will be returned; If $first is false, an array will be returned.

getCount() 公共 方法

Returns the number of headers in the collection.

public integer getCount()
return integer

The number of headers in the collection.

getIterator() 公共 方法

Returns an iterator for traversing the headers in the collection.

This method is required by the SPL interface IteratorAggregate. It will be implicitly called when you use foreach to traverse the collection.

public ArrayIterator getIterator()
return ArrayIterator

An iterator for traversing the headers in the collection.

has() 公共 方法

Returns a value indicating whether the named header exists.

public boolean has($name)
$name string

The name of the header

return boolean

Whether the named header exists

offsetExists() 公共 方法

Returns whether there is a header with the specified name.

This method is required by the SPL interface ArrayAccess. It is implicitly called when you use something like isset($collection[$name]).

public boolean offsetExists($name)
$name string

The header name

return boolean

Whether the named header exists

offsetGet() 公共 方法

Returns the header with the specified name.

This method is required by the SPL interface ArrayAccess. It is implicitly called when you use something like $header = $collection[$name];. This is equivalent to get().

public string offsetGet($name)
$name string

The header name

return string

The header value with the specified name, null if the named header does not exist.

offsetSet() 公共 方法

Adds the header to the collection.

This method is required by the SPL interface ArrayAccess. It is implicitly called when you use something like $collection[$name] = $header;. This is equivalent to add().

public void offsetSet($name, $value)
$name string

The header name

$value string

The header value to be added

offsetUnset() 公共 方法

Removes the named header.

This method is required by the SPL interface ArrayAccess. It is implicitly called when you use something like unset($collection[$name]). This is equivalent to remove().

public void offsetUnset($name)
$name string

The header name

remove() 公共 方法

Removes a header.

public array remove($name)
$name string

The name of the header to be removed.

return array

The value of the removed header. Null is returned if the header does not exist.

removeAll() 公共 方法

Removes all headers.

public void removeAll()
set() 公共 方法

Adds a new header.

If there is already a header with the same name, it will be replaced.

public $this set($name, $value '')
$name string

The name of the header

$value string

The value of the header

return $this

The collection object itself

setDefault() 公共 方法

Sets a new header only if it does not exist yet.

If there is already a header with the same name, the new one will be ignored.

public $this setDefault($name, $value)
$name string

The name of the header

$value string

The value of the header

return $this

The collection object itself

toArray() 公共 方法

Returns the collection as a PHP array.

public array toArray()
return array

The array representation of the collection. The array keys are header names, and the array values are the corresponding header values.