HTTPHeader is a PHP class for inspecting HTTP request headers.
- PHP 5.4+
Methods read from the $_SERVER
superglobal. Alternatively a string containing a header (with or without field name) can be supplied as an argument. Methods will return false
if the request header is not present or cannot be parsed.
Returns an array sorted by "q" value.
Example:
Array
(
[0] => text/html
[1] => application/xhtml+xml
[2] => image/webp
[3] => application/xml;q=0.9
[4] => */*;q=0.8
)
Returns an array sorted by "q" value.
Example:
Array
(
[0] => gzip
[1] => deflate
)
Returns an array sorted by "q" value.
Example:
Array
(
[0] => en-GB
[1] => en;q=0.7
[2] => en-US;q=0.3
)
Returns an array containing the authorization type and credentials.
Example:
Array
(
[0] => Basic
[1] => YWxhZGRpbjpvcGVuc2VzYW1l
)
Returns an array of directives.
Example:
Array
(
[0] => only-if-cached
)
Returns an array of directives.
Example:
Array
(
[0] => keep-alive
)
Returns an associative array containing the content type, charset and boundary if supplied.
Example:
Array
(
[type] => multipart/form-data
[boundary] => something
)
Returns an associative array of cookie names and values.
Example:
Array
(
[Session] => 0ae5ab57925bcbee58917d552acb4cd4
)
Returns a DateTimeImmutable object.
Example:
DateTimeImmutable Object
(
[date] => 2015-10-21 07:28:00.000000
[timezone_type] => 2
[timezone] => GMT
)
Returns 0, 1, or null
if the value is indeterminate.
Returns an array of fields, each containing an associative array of directives.
Example:
Array
(
[0] => Array
(
[for] => 192.0.2.60
[proto] => http
[by] => 203.0.113.43
)
[1] => Array
(
[for] => 198.51.100.17
)
)
Returns a string containing the supplied email address.
Returns an associative array containing the host, and port if supplied.
Example:
Array
(
[host] => example.com
[port] => 80
)
Returns an array of ETag values.
Example:
Array
(
[0] => W/"67ab43"
[1] => "54ed21"
[2] => "7892dd"
)
Returns a DateTimeImmutable object.
Example:
DateTimeImmutable Object
(
[date] => 2015-10-21 07:28:00.000000
[timezone_type] => 2
[timezone] => GMT
)
Returns an array of ETag values.
Example:
Array
(
[0] => W/"67ab43"
[1] => "54ed21"
[2] => "7892dd"
)
Returns a DateTimeImmutable object, or an array of ETag values.
Returns a DateTimeImmutable object.
Example:
DateTimeImmutable Object
(
[date] => 2015-10-21 07:28:00.000000
[timezone_type] => 2
[timezone] => GMT
)
Returns an associative array of parameters.
Example:
Array
(
[timeout] => 5
[max] => 1000
)
Returns the result of parse_url()
on the supplied value.
Example:
Array
(
[scheme] => https
[host] => example.com
)
Returns an array containing the authorization type and credentials.
Example:
Array
(
[0] => Basic
[1] => YWxhZGRpbjpvcGVuc2VzYW1l
)
Returns an associative array containing the unit and ranges.
Example:
Array
(
[unit] => bytes
[ranges] => Array
(
[0] => 200-1000
[1] => 2000-6576
[2] => 19000-
)
)
Returns the result of parse_url()
on the supplied value.
Example:
Array
(
[scheme] => https
[host] => example.com
[path] => /foo/
)
Returns 0 for falsey values, 1 for truthy values, or null
if the value is indeterminate.
Returns an array sorted by "q" value.
Example:
Array
(
[0] => trailers
[1] => gzip
[2] => deflate;q=0.5
)
Returns 0, 1, or null
if the value is indeterminate.
Returns an associative array containing the product, version, and comment.
Example:
Array
(
[product] => Mozilla
[version] => 5.0
[comment] => (Windows NT 10.0; Win64; x64; rv:84.0) Gecko/20100101 Firefox/84.0
)
Returns an array of proxy identifiers.
Example:
Array
(
[0] => 1.0 foo
[1] => 1.1 bar.example.com
)
Returns an array sorted by "q" value.
Example:
Array
(
[0] => sha-256;q=1
[1] => SHA-512;q=0.3
[2] => md5;q=0
)