CodeIgniter v4.5 API

Header
in package
implements Stringable

Class Header

Represents a single HTTP header.

Tags
see
HeaderTest

Table of Contents

Interfaces

Stringable

Properties

$name  : string
The name of the header.
$value  : array<int|string, array<string, string>|string>|string
The value of the header. May have more than one value. If so, will be an array of strings.

Methods

__construct()  : mixed
Header constructor. name is mandatory, if a value is provided, it will be set.
__toString()  : string
Returns a representation of the entire header string, including the header name and all values converted to the proper format.
appendValue()  : $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.
getName()  : string
Returns the name of the header, in the same case it was set.
getValue()  : array<int|string, array<string, string>|string>|string
Gets the raw value of the header. This may return either a string or an array, depending on whether the header has multiple values or not.
getValueLine()  : string
Retrieves a comma-separated string of the values for a single header.
prependValue()  : $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.
setName()  : $this
Sets the name of the header, overwriting any previous value.
setValue()  : $this
Sets the value of the header, overwriting any previous value(s).

Properties

$name

The name of the header.

protected string $name

$value

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

protected array<int|string, array<string, string>|string>|string $value

E.g., [ 'foo', [ 'bar' => 'fizz', ], 'baz' => 'buzz', ]

Methods

__construct()

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

public __construct(string $name[, array<int|string, array<string, string>|string>|string|null $value = null ]) : mixed
Parameters
$name : string
$value : array<int|string, array<string, string>|string>|string|null = null

__toString()

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

public __toString() : string
Return values
string

appendValue()

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.

public appendValue([array<string, string>|string|null $value = null ]) : $this
Parameters
$value : array<string, string>|string|null = null
Return values
$this

getName()

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

public getName() : string
Return values
string

getValue()

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

public getValue() : array<int|string, array<string, string>|string>|string
Return values
array<int|string, array<string, string>|string>|string

getValueLine()

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

public getValueLine() : string

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.

Tags
see
https://www.w3.org/Protocols/rfc2616/rfc2616-sec4.html#sec4.2
Return values
string

prependValue()

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.

public prependValue([array<string, string>|string|null $value = null ]) : $this
Parameters
$value : array<string, string>|string|null = null
Return values
$this

setName()

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

public setName(string $name) : $this
Parameters
$name : string
Return values
$this

setValue()

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

public setValue([array<int|string, array<string, string>|string>|string|null $value = null ]) : $this
Parameters
$value : array<int|string, array<string, string>|string>|string|null = null
Return values
$this

        
On this page

Search results