PHP 클래스 yii\web\HeaderCollection

부터: 2.0
저자: Qiang Xue ([email protected])
상속: extends yii\base\Object, implements IteratorAggregate, implements ArrayAccess, implements Countable
파일 보기 프로젝트 열기: yiisoft/yii2 1 사용 예제들

공개 메소드들

메소드 설명
add ( string $name, string $value ) Adds a new header.
count ( ) : integer Returns the number of headers in the collection.
fromArray ( array $array ) Populates the header collection from an array.
get ( string $name, mixed $default = null, boolean $first = true ) : string | array Returns the named header(s).
getCount ( ) : integer Returns the number of headers in the collection.
getIterator ( ) : ArrayIterator Returns an iterator for traversing the headers in the collection.
has ( string $name ) : boolean Returns a value indicating whether the named header exists.
offsetExists ( string $name ) : boolean Returns whether there is a header with the specified name.
offsetGet ( string $name ) : string Returns the header with the specified name.
offsetSet ( string $name, string $value ) Adds the header to the collection.
offsetUnset ( string $name ) Removes the named header.
remove ( string $name ) : array Removes a header.
removeAll ( ) Removes all headers.
set ( string $name, string $value = '' ) Adds a new header.
setDefault ( string $name, string $value ) Sets a new header only if it does not exist yet.
toArray ( ) : array Returns the collection as a PHP array.

메소드 상세

add() 공개 메소드

If there is already a header with the same name, the new one will be appended to it instead of replacing it.
public add ( string $name, string $value )
$name string the name of the header
$value string the value of the header

count() 공개 메소드

This method is required by the SPL Countable interface. It will be implicitly called when you use count($collection).
public count ( ) : integer
리턴 integer the number of headers in the collection.

fromArray() 공개 메소드

Populates the header collection from an array.
부터: 2.0.3
public fromArray ( array $array )
$array array the headers to populate from

get() 공개 메소드

Returns the named header(s).
public get ( string $name, mixed $default = null, boolean $first = true ) : string | array
$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.
리턴 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 getCount ( ) : integer
리턴 integer the number of headers in the collection.

getIterator() 공개 메소드

This method is required by the SPL interface [[\IteratorAggregate]]. It will be implicitly called when you use foreach to traverse the collection.
public getIterator ( ) : ArrayIterator
리턴 ArrayIterator an iterator for traversing the headers in the collection.

has() 공개 메소드

Returns a value indicating whether the named header exists.
public has ( string $name ) : boolean
$name string the name of the header
리턴 boolean whether the named header exists

offsetExists() 공개 메소드

This method is required by the SPL interface [[\ArrayAccess]]. It is implicitly called when you use something like isset($collection[$name]).
public offsetExists ( string $name ) : boolean
$name string the header name
리턴 boolean whether the named header exists

offsetGet() 공개 메소드

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 HeaderCollection::get.
public offsetGet ( string $name ) : string
$name string the header name
리턴 string the header value with the specified name, null if the named header does not exist.

offsetSet() 공개 메소드

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 HeaderCollection::add.
public offsetSet ( string $name, string $value )
$name string the header name
$value string the header value to be added

offsetUnset() 공개 메소드

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 HeaderCollection::remove.
public offsetUnset ( string $name )
$name string the header name

remove() 공개 메소드

Removes a header.
public remove ( string $name ) : array
$name string the name of the header to be removed.
리턴 array the value of the removed header. Null is returned if the header does not exist.

removeAll() 공개 메소드

Removes all headers.
public removeAll ( )

set() 공개 메소드

If there is already a header with the same name, it will be replaced.
public set ( string $name, string $value = '' )
$name string the name of the header
$value string the value of the header

setDefault() 공개 메소드

If there is already a header with the same name, the new one will be ignored.
public setDefault ( string $name, string $value )
$name string the name of the header
$value string the value of the header

toArray() 공개 메소드

Returns the collection as a PHP array.
public toArray ( ) : array
리턴 array the array representation of the collection. The array keys are header names, and the array values are the corresponding header values.