\CodeIgniter\HTTPHeader

Class Header

Represents a single HTTP header.

Summary

Methods
Properties
Constants
__construct()
getName()
getValue()
setName()
setValue()
appendValue()
prependValue()
getValueLine()
__toString()
No public properties found
No constants found
No protected methods found
$name
$value
N/A
No private methods found
No private properties found
N/A

Properties

$name

$name : string

The name of the header.

Type

string

$value

$value : string|array

The value of the header. May have more than one value. If so, will be an array of strings.

Type

string|array

Methods

__construct()

__construct(string  $name, string|array|null  $value = null) 

Header constructor. name is mandatory, if a value is provided, it will be set.

Parameters

string $name
string|array|null $value

getName()

getName() : string

Returns the name of the header, in the same case it was set.

Returns

string

getValue()

getValue() : array|null|string

Gets the raw value of the header. This may return either a string of an array, depending on whether the header has multiple values or not.

Returns

array|null|string

setName()

setName(string  $name) : $this

Sets the name of the header, overwriting any previous value.

Parameters

string $name

Returns

$this

setValue()

setValue(null  $value = null) : $this

Sets the value of the header, overwriting any previous value(s).

Parameters

null $value

Returns

$this

appendValue()

appendValue(null  $value = null) : $this

Appends a value to the list of values for this header. If the header is a single value string, it will be converted to an array.

Parameters

null $value

Returns

$this

prependValue()

prependValue(null  $value = null) : $this

Prepends a value to the list of values for this header. If the header is a single value string, it will be converted to an array.

Parameters

null $value

Returns

$this

getValueLine()

getValueLine() 

Retrieves a comma-separated string of the values for a single header.

NOTE: Not all header values may be appropriately represented using comma concatenation. For such headers, use getHeader() instead and supply your own delimiter when concatenating.

__toString()

__toString() : string

Returns a representation of the entire header string, including the header name and all values converted to the proper format.

Returns

string