Class Headers
HTTP Header field definitions.
Instances of this class are used to collect and manipulate HTTP header field
definitions. Header field instances are used to handle the definition of complex
header fields such as Content-Type
and Cache-Control
.
For instance a Headers\CacheControl instance is used to handle the
directives of the Cache-Control
header field.
-
ICanBoogie\HTTP\Headers
implements
ArrayAccess,
IteratorAggregate
Methods summary
public
|
#
__construct( array $fields = array() )
If the REQUEST_URI key is found in the header fields they are
considered coming from the super global $_SERVER array in which
case they are filtered to keep only keys starting with the HTTP_
prefix. Also, header field names are normalized. For instance,
HTTP_CONTENT_TYPE becomes Content-Type .
If the REQUEST_URI key is found in the header fields they are
considered coming from the super global $_SERVER array in which
case they are filtered to keep only keys starting with the HTTP_
prefix. Also, header field names are normalized. For instance,
HTTP_CONTENT_TYPE becomes Content-Type .
Parameters
- $fields
array $headers The initial headers.
|
public
string
|
#
__toString( )
Returns the header as a string.
Returns the header as a string.
Header fields with empty string values are discarted.
Returns
string
|
public
|
#
__invoke( )
Sends header fields using the header() function.
Sends header fields using the header() function.
Header fields with empty string values are discarted.
|
public
boolean
|
#
offsetExists( mixed $field )
Checks if a header field exists.
Checks if a header field exists.
Parameters
Returns
boolean
Implementation of
|
public
string|null
|
#
offsetGet( mixed $field )
Returns a header.
Parameters
Returns
string|null The header field value or null if it is not defined.
Implementation of
|
public
|
#
offsetSet( string $field, mixed $value )
Sets a header field.
Note: Setting a header field to null removes it, just like
unset() would.
Date, Expires, Last-Modified
The Date , Expires and Last-Modified
header fields can be provided as a Unix timestamp, a string or a DateTime object.
Cache-Control, Content-Disposition and Content-Type
Instances of the Headers\CacheControl, Headers\ContentDisposition and Headers\ContentType are used to handle
the values of the Cache-Control , Content-Disposition
and Content-Type header fields.
Parameters
- $field
string $field The header field to set.
- $value
mixed $value The value of the header field.
Implementation of
|
public
|
#
offsetUnset( mixed $field )
Removes a header field.
Implementation of
|
public
|
#
getIterator( )
Returns an iterator for the header fields.
Returns an iterator for the header fields.
Implementation of
|
Magic methods summary
Properties summary
protected
array[string]mixed
|
$fields
|
|