HTTPHeader is a PHP class for inspecting HTTP headers.
- PHP 8.0+
Methods for inspecting response headers must be supplied with a string containing one or more headers, or a complete HTTP response.
Examples:
use xenocrat\HTTPHeader;
$result = HTTPHeader::Server("Server: Apache");
$result = HTTPHeader::Server("Content-Type: text/plain\r\nServer: Apache");
$result = HTTPHeader::Server("HTTP/1.1 200 OK\r\nServer: Apache\r\n\r\nHello, world!");Methods for inspecting request headers can optionally be supplied with a string containing one or more headers, or a complete HTTP request; if not supplied with a string, these methods will attempt to read the value from the $_SERVER superglobal.
Examples:
use xenocrat\HTTPHeader;
$result = HTTPHeader::Accept();
$result = HTTPHeader::Accept("Accept: text/html, application/xhtml+xml");
$result = HTTPHeader::Accept("Accept: text/html\r\nAccept-Encoding: gzip");public static HTTPHeader::extract(
string $string
): arrayExtract all header fields from a string containing multiple headers, or from a complete HTTP message.
-
$string
A string containing one or more headers, or a complete HTTP message.
Returns an associative array of arrays containing one entry for each occurence of a field.
Array
(
[CONTENT_TYPE] => Array
(
[0] => Array
(
[type] => text/plain
)
)
[SERVER] => Array
(
[0] => Array
(
[0] => Array
(
[product] => Apache
)
)
)
)
public static HTTPHeader::Accept(
string $string = null
): array|null|false-
$string
A string containing one or more headers, or a complete HTTP message.
Returns an array sorted by "q" value. Returns false if the header field is not present or empty, and null if the field value is noticeably malformed.
Array
(
[0] => text/html
[1] => application/xhtml+xml
[2] => image/webp
[3] => application/xml;q=0.9
[4] => */*;q=0.8
)
public static HTTPHeader::Accept_CH(
string $string
): array|null|false-
$string
A string containing one or more headers, or a complete HTTP message.
Returns an array of client hint headers. Returns false if the header field is not present or empty, and null if the field value is noticeably malformed.
public static HTTPHeader::Accept_Charset(
string $string = null
): array|null|false-
$string
A string containing one or more headers, or a complete HTTP message.
Returns an array sorted by "q" value. Returns false if the header field is not present or empty, and null if the field value is noticeably malformed.
public static HTTPHeader::Accept_Encoding(
string $string = null
): array|null|false-
$string
A string containing one or more headers, or a complete HTTP message.
Returns an array sorted by "q" value. Returns false if the header field is not present or empty, and null if the field value is noticeably malformed.
Array
(
[0] => gzip
[1] => deflate
)
public static HTTPHeader::Accept_Language(
string $string = null
): array|null|false-
$string
A string containing one or more headers, or a complete HTTP message.
Returns an array sorted by "q" value. Returns false if the header field is not present or empty, and null if the field value is noticeably malformed.
Array
(
[0] => en-GB
[1] => en;q=0.7
[2] => en-US;q=0.3
)
public static HTTPHeader::Accept_Patch(
string $string
): array|null|false-
$string
A string containing one or more headers, or a complete HTTP message.
Returns an array of media types. Returns false if the header field is not present or empty, and null if the field value is noticeably malformed.
Array
(
[0] => application/example
[1] => text/example;charset=utf-8
)
public static HTTPHeader::Accept_Post(
string $string
): array|null|false-
$string
A string containing one or more headers, or a complete HTTP message.
Returns an array of media types. Returns false if the header field is not present or empty, and null if the field value is noticeably malformed.
Array
(
[0] => image/webp
[1] => text/example;charset=utf-8
)
public static HTTPHeader::Accept_Ranges(
string $string
): string|false-
$string
A string containing one or more headers, or a complete HTTP message.
Returns a range unit. Returns false if the header field is not present or empty.
public static HTTPHeader::Access_Control_Allow_Credentials(
string $string
): ?bool-
$string
A string containing one or more headers, or a complete HTTP message.
Returns true if the value is "true", or null otherwise.
public static HTTPHeader::Access_Control_Allow_Headers(
string $string
): array|null|false-
$string
A string containing one or more headers, or a complete HTTP message.
Returns an array of headers. Returns false if the header field is not present or empty, and null if the field value is noticeably malformed.
Array
(
[0] => Accept
[1] => Upgrade-Insecure-Requests
)
public static HTTPHeader::Access_Control_Allow_Methods(
string $string
): array|null|false-
$string
A string containing one or more headers, or a complete HTTP message.
Returns an array of method names. Returns false if the header field is not present or empty, and null if the field value is noticeably malformed.
Array
(
[0] => POST
[1] => GET
[2] => OPTIONS
)
public static HTTPHeader::Access_Control_Allow_Origin(
string $string
): string|array|null|false-
$string
A string containing one or more headers, or a complete HTTP message.
Returns the string "*", the string "null" if the value is "null", or the result of parse_url() on the supplied value. Returns false if the header field is not present or empty.
public static HTTPHeader::Access_Control_Expose_Headers(
string $string
): array|null|false-
$string
A string containing one or more headers, or a complete HTTP message.
Returns an array of headers. Returns false if the header field is not present or empty, and null if the field value is noticeably malformed.
Array
(
[0] => Content-Encoding
)
public static HTTPHeader::Access_Control_Max_Age(
string $string
): int|null|false-
$string
A string containing one or more headers, or a complete HTTP message.
Returns a non-negative integer representing the number of seconds. Returns false if the header field is not present or empty, and null if the field value is noticeably malformed.
public static HTTPHeader::Access_Control_Request_Headers(
string $string = null
): array|null|false-
$string
A string containing one or more headers, or a complete HTTP message.
Returns an array of headers. Returns false if the header field is not present or empty, and null if the field value is noticeably malformed.
Array
(
[0] => Content-Type
)
public static HTTPHeader::Access_Control_Request_Method(
string $string = null
): string|null|false-
$string
A string containing one or more headers, or a complete HTTP message.
Returns the method name. Returns false if the header field is not present or empty, and null if the field value is noticeably malformed.
public static HTTPHeader::Activate_Storage_Access(
string $string
): array|null|false-
$string
A string containing one or more headers, or a complete HTTP message.
Returns an array containing the directive and parameters. Returns false if the header field is not present or empty, and null if the field value is noticeably malformed.
public static HTTPHeader::Age(
string $string
): int|null|false-
$string
A string containing one or more headers, or a complete HTTP message.
Returns a non-negative integer representing a time delta in seconds. Returns false if the header field is not present or empty, and null if the field value is noticeably malformed.
public static HTTPHeader::Allow(
string $string
): array|null|false-
$string
A string containing one or more headers, or a complete HTTP message.
Returns an array of method names. Returns false if the header field is not present or empty, and null if the field value is noticeably malformed.
Array
(
[0] => GET
[1] => POST
[2] => HEAD
)
public static HTTPHeader::Alt_Svc(
string $string
): string|array|null|false-
$string
A string containing one or more headers, or a complete HTTP message.
Returns the string "clear", or an array of associative arrays containing the parameters for each alternative service. Returns false if the header field is not present or empty, and null if the field value is noticeably malformed.
Array
(
[0] => Array
(
[protocol] => h3-25
[host] =>
[port] => 443
[ma] => 3600
[persist] => <true|false>
)
[1] => Array
(
[protocol] => h2
[host] => example.com
[port] => 443
[ma] => 3600
[persist] => <true|false>
)
)
public static HTTPHeader::Alt_Used(
string $string = null
): array|null|false-
$string
A string containing one or more headers, or a complete HTTP message.
Returns an associative array containing the host, and port if supplied. Returns false if the header field is not present or empty, and null if the field value is noticeably malformed.
Array
(
[host] => example.com
[port] => 80
)
public static HTTPHeader::Authorization(
string $string = null
): array|null|false-
$string
A string containing one or more headers, or a complete HTTP message.
Returns an array containing the authorization type and parameters. Returns false if the header field is not present or empty, and null if the field value is noticeably malformed.
Array
(
[0] => Basic
[1] => YWxhZGRpbjpvcGVuc2VzYW1l
)
public static HTTPHeader::Cache_Control(
string $string = null
): array|null|false-
$string
A string containing one or more headers, or a complete HTTP message.
Returns an array of directives. Returns false if the header field is not present or empty, and null if the field value is noticeably malformed.
Array
(
[0] => only-if-cached
)
public static HTTPHeader::Clear_Site_Data(
string $string
): array|null|false-
$string
A string containing one or more headers, or a complete HTTP message.
Returns an array of directives. Returns false if the header field is not present or empty, and null if the field value is noticeably malformed.
Array
(
[0] => storage
[1] => cookies
)
public static HTTPHeader::Connection(
string $string = null
): array|null|false-
$string
A string containing one or more headers, or a complete HTTP message.
Returns an array of directives. Returns false if the header field is not present or empty, and null if the field value is noticeably malformed.
Array
(
[0] => keep-alive
)
public static HTTPHeader::Content_Disposition(
string $string
): array|null|false-
$string
A string containing one or more headers, or a complete HTTP message.
Returns an associative array containing the content disposition, field name and filename (if supplied). Returns false if the header field is not present or empty, and null if the field value is noticeably malformed.
Array
(
[disposition] => attachment
[filename] => filename.jpg
)
public static HTTPHeader::Content_Encoding(
string $string
): array|null|false-
$string
A string containing one or more headers, or a complete HTTP message.
Returns an array of encoding formats in the order in which they were applied. Returns false if the header field is not present or empty, and null if the field value is noticeably malformed.
Array
(
[0] => deflate
[1] => gzip
)
public static HTTPHeader::Content_Language(
string $string = null
): array|null|false-
$string
A string containing one or more headers, or a complete HTTP message.
Returns an array of language tags. Returns false if the header field is not present or empty, and null if the field value is noticeably malformed.
Array
(
[0] => en-GB
[1] => en
)
public static HTTPHeader::Content_Length(
string $string = null
): int|null|false-
$string
A string containing one or more headers, or a complete HTTP message.
Returns the content length in decimal number of octets. Returns false if the header field is not present or empty, and null if the field value is noticeably malformed.
public static HTTPHeader::Content_Location(
string $string
): string|false-
$string
A string containing one or more headers, or a complete HTTP message.
Returns a string. Returns false if the header field is not present or empty, and null if the field value is noticeably malformed.
public static HTTPHeader::Content_Range(
string $string
): array|null|false-
$string
A string containing one or more headers, or a complete HTTP message.
Returns an associative array containing the unit, range, and size. Returns false if the header field is not present or empty, and null if the field value is noticeably malformed.
Array
(
[unit] => bytes
[range] => 200-1000
[size] => 67589
)
public static HTTPHeader::Content_Security_Policy(
string $string
): array|null|false-
$string
A string containing one or more headers, or a complete HTTP message.
Returns an array of arrays containing the policy directive and values. Returns false if the header field is not present or empty, and null if the field value is noticeably malformed.
Array
(
[0] => Array
(
[0] => default-src
[1] => Array
(
[0] => self
[1] => nonce-DhcnhD3khTMePgXwdayK9BsMqXjhguVV
)
)
[1] => Array
(
[0] => form-action
[1] => Array
(
[0] => self
)
)
public static HTTPHeader::Content_Security_Policy_Report_Only(
string $string
): array|null|false-
$string
A string containing one or more headers, or a complete HTTP message.
Returns an array of arrays containing the policy directive and values. Returns false if the header field is not present or empty, and null if the field value is noticeably malformed.
public static HTTPHeader::Content_Type(
string $string = null
): array|null|false-
$string
A string containing one or more headers, or a complete HTTP message.
Returns an associative array containing the content type, charset and boundary (if supplied). Returns false if the header field is not present or empty, and null if the field value is noticeably malformed.
Array
(
[type] => multipart/form-data
[boundary] => something
)
public static HTTPHeader::Cookie(
string $string = null
): array|null|false-
$string
A string containing one or more headers, or a complete HTTP message.
Returns an array of arrays containing the cookie names and value. Returns false if the header field is not present or empty, and null if the field value is noticeably malformed.
Array
(
[0] => Array
(
[0] => Session
[1] => 0ae5ab57925bcbee58917d552acb4cd4
)
)
public static HTTPHeader::Cross_Origin_Embedder_Policy(
string $string
): string|null|false-
$string
A string containing one or more headers, or a complete HTTP message.
Returns a policy directive. Returns false if the header field is not present or empty, and null if the field value is noticeably malformed.
public static HTTPHeader::Cross_Origin_Opener_Policy(
string $string
): string|null|false-
$string
A string containing one or more headers, or a complete HTTP message.
Returns a policy directive. Returns false if the header field is not present or empty, and null if the field value is noticeably malformed.
public static HTTPHeader::Cross_Origin_Resource_Policy(
string $string
): string|null|false-
$string
A string containing one or more headers, or a complete HTTP message.
Returns a policy directive. Returns false if the header field is not present or empty, and null if the field value is noticeably malformed.
public static HTTPHeader::Date(
string $string = null
): \DateTimeImmutable|null|false-
$string
A string containing one or more headers, or a complete HTTP message.
Returns a DateTimeImmutable object. Returns false if the header field is not present or empty, and null if the field value is noticeably malformed.
DateTimeImmutable Object
(
[date] => 2015-10-21 07:28:00.000000
[timezone_type] => 2
[timezone] => GMT
)
public static HTTPHeader::Device_Memory(
string $string = null
): float|null|false-
$string
A string containing one or more headers, or a complete HTTP message.
Returns a non-negative float representing the device memory in GiB. Returns false if the header field is not present or empty, and null if the field value is noticeably malformed.
public static HTTPHeader::Digest(
string $string
): array|null|false-
$string
A string containing one or more headers, or a complete HTTP message.
Returns an array of arrays containing the digest algorithms and values. Returns false if the header field is not present or empty, and null if the field value is noticeably malformed.
Array
(
[0] => Array
(
[0] => sha-256
[1] => X48E9qOokqqrvdts8nOJRJN3OWDUoyWxBf7kbu9DBPE=
)
[1] => Array
(
[0] => unixsum
[1] => 30637
)
)
public static HTTPHeader::Downlink(
string $string = null
): float|null|false-
$string
A string containing one or more headers, or a complete HTTP message.
Returns a non-negative float representing the downlink rate in Mbps. Returns false if the header field is not present or empty, and null if the field value is noticeably malformed.
public static HTTPHeader::DNT(
string $string = null
): int|null|false-
$string
A string containing one or more headers, or a complete HTTP message.
Returns the integer 0, 1, or null if the value is indeterminate. Returns false if the header field is not present or empty.
public static HTTPHeader::ECT(
string $string = null
): string|null|false-
$string
A string containing one or more headers, or a complete HTTP message.
Returns a string identifying the effective connection type, or null if the value is indeterminate. Returns false if the header field is not present or empty.
public static HTTPHeader::ETag(
string $string
): string|null|false-
$string
A string containing one or more headers, or a complete HTTP message.
Returns an ETag value. Returns false if the header field is not present or empty, and null if the field value is noticeably malformed.
public static HTTPHeader::Expect(
string $string = null
): int|null|false-
$string
A string containing one or more headers, or a complete HTTP message.
Returns the integer 100 if the value is "100-continue", or null otherwise. Returns false if the header field is not present or empty.
public static HTTPHeader::Expires(
string $string
): \DateTimeImmutable|null|false-
$string
A string containing one or more headers, or a complete HTTP message.
Returns a DateTimeImmutable object. Returns false if the header field is not present or empty, and null if the field value is noticeably malformed.
DateTimeImmutable Object
(
[date] => 2015-10-21 07:28:00.000000
[timezone_type] => 2
[timezone] => GMT
)
public static HTTPHeader::Forwarded(
string $string = null
): array|null|false-
$string
A string containing one or more headers, or a complete HTTP message.
Returns an array of fields, each containing an associative array of directives. Returns false if the header field is not present or empty, and null if the field value is noticeably malformed.
Array
(
[0] => Array
(
[for] => 192.0.2.60
[proto] => http
[by] => 203.0.113.43
)
[1] => Array
(
[for] => 198.51.100.17
)
)
public static HTTPHeader::From(
string $string = null
): string|null|false-
$string
A string containing one or more headers, or a complete HTTP message.
Returns a string containing the supplied email address. Returns false if the header field is not present or empty, and null if the field value is noticeably malformed.
public static HTTPHeader::Host(
string $string = null
): array|null|false-
$string
A string containing one or more headers, or a complete HTTP message.
Returns an associative array containing the host, and port if supplied. Returns false if the header field is not present or empty, and null if the field value is noticeably malformed.
Array
(
[host] => example.com
[port] => 80
)
public static HTTPHeader::If_Match(
string $string = null
): array|null|false-
$string
A string containing one or more headers, or a complete HTTP message.
Returns an array of ETag values. Returns false if the header field is not present or empty, and null if the field value is noticeably malformed.
Array
(
[0] => W/"67ab43"
[1] => "54ed21"
[2] => "7892dd"
)
public static HTTPHeader::If_Modified_Since(
string $string = null
): \DateTimeImmutable|null|false-
$string
A string containing one or more headers, or a complete HTTP message.
Returns a DateTimeImmutable object. Returns false if the header field is not present or empty, and null if the field value is noticeably malformed.
DateTimeImmutable Object
(
[date] => 2015-10-21 07:28:00.000000
[timezone_type] => 2
[timezone] => GMT
)
public static HTTPHeader::If_None_Match(
string $string = null
): array|null|false-
$string
A string containing one or more headers, or a complete HTTP message.
Returns an array of ETag values. Returns false if the header field is not present or empty, and null if the field value is noticeably malformed.
Array
(
[0] => W/"67ab43"
[1] => "54ed21"
[2] => "7892dd"
)
public static HTTPHeader::If_Range(
string $string = null
): \DateTimeImmutable|string|null|false-
$string
A string containing one or more headers, or a complete HTTP message.
Returns a DateTimeImmutable object, or an ETag value. Returns false if the header field is not present or empty, and null if the field value is noticeably malformed.
public static HTTPHeader::If_Unmodified_Since(
string $string = null
): \DateTimeImmutable|null|false-
$string
A string containing one or more headers, or a complete HTTP message.
Returns a DateTimeImmutable object. Returns false if the header field is not present or empty, and null if the field value is noticeably malformed.
DateTimeImmutable Object
(
[date] => 2015-10-21 07:28:00.000000
[timezone_type] => 2
[timezone] => GMT
)
public static HTTPHeader::Keep_Alive(
string $string = null
): array|null|false-
$string
A string containing one or more headers, or a complete HTTP message.
Returns an associative array of parameters. Returns false if the header field is not present or empty, and null if the field value is noticeably malformed.
Array
(
[timeout] => 5
[max] => 1000
)
public static HTTPHeader::Last_Modified(
string $string
): \DateTimeImmutable|null|false-
$string
A string containing one or more headers, or a complete HTTP message.
Returns a DateTimeImmutable object. Returns false if the header field is not present or empty, and null if the field value is noticeably malformed.
DateTimeImmutable Object
(
[date] => 2015-10-21 07:28:00.000000
[timezone_type] => 2
[timezone] => GMT
)
public static HTTPHeader::Link(
string $string
): array|null|false-
$string
A string containing one or more headers, or a complete HTTP message.
Returns an array of arrays containing the link URI and an array of parameters. Returns false if the header field is not present or empty, and null if the field value is noticeably malformed.
Array
(
[0] => Array
(
[0] => https://one.example.com
[1] => Array
(
[0] => Array
(
[0] => rel
[1] => preconnect
)
)
)
[1] => Array
(
[0] => https://two.example.com
[1] => Array
(
[0] => Array
(
[0] => rel
[1] => preconnect
)
[1] => Array
(
[0] => foo
[1] => bar
)
)
)
)
public static HTTPHeader::Location(
string $string
): string|false-
$string
A string containing one or more headers, or a complete HTTP message.
Returns a string. Returns false if the header field is not present or empty.
public static HTTPHeader::Max_Forwards(
string $string = null
): int|null|false-
$string
A string containing one or more headers, or a complete HTTP message.
Returns a non-negative integer. Returns false if the header field is not present or empty, and null if the field value is noticeably malformed.
public static HTTPHeader::Origin(
string $string = null
): array|null|false-
$string
A string containing one or more headers, or a complete HTTP message.
Returns the result of parse_url() on the supplied value. Returns false if the header field is not present or empty, and null if the field value is noticeably malformed.
Array
(
[scheme] => https
[host] => example.com
)
public static HTTPHeader::Permissions_Policy(
string $string
): array|null|false-
$string
A string containing one or more headers, or a complete HTTP message.
Returns an array of arrays containing the policy directive and values. Returns false if the header field is not present or empty, and null if the field value is noticeably malformed.
Array
(
[0] => Array
(
[0] => picture-in-picture
[1] => Array
(
)
)
[1] => Array
(
[0] => geolocation
[1] => Array
(
[0] => self
[1] => https://example.com
)
)
[2] => Array
(
[0] => camera
[1] => Array
(
[0] => *
)
)
)
public static HTTPHeader::Pragme(
string $string = null
): array|null|false-
$string
A string containing one or more headers, or a complete HTTP message.
Returns an array of directives. Returns false if the header field is not present or empty, and null if the field value is noticeably malformed.
public static HTTPHeader::Proxy_Authenticate(
string $string
): array|null|false-
$string
A string containing one or more headers, or a complete HTTP message.
Returns an array of arrays containing the authentication type and parameters. Returns false if the header field is not present or empty, and null if the field value is noticeably malformed.
Array
(
[0] => Array
(
[0] => Basic
[1] => realm="foo"
)
[1] => Array
(
[0] => Other
[1] => realm="bar"
)
)
public static HTTPHeader::Proxy_Authorization(
string $string = null
): array|null|false-
$string
A string containing one or more headers, or a complete HTTP message.
Returns an array containing the authorization type and parameters. Returns false if the header field is not present or empty, and null if the field value is noticeably malformed.
Array
(
[0] => Basic
[1] => YWxhZGRpbjpvcGVuc2VzYW1l
)
public static HTTPHeader::Range(
string $string = null
): array|null|false-
$string
A string containing one or more headers, or a complete HTTP message.
Returns an associative array containing the unit and ranges. Returns false if the header field is not present or empty, and null if the field value is noticeably malformed.
Array
(
[unit] => bytes
[ranges] => Array
(
[0] => 200-1000
[1] => 2000-6576
[2] => 19000-
)
)
public static HTTPHeader::Referer(
string $string = null
): array|null|false-
$string
A string containing one or more headers, or a complete HTTP message.
Returns the result of parse_url() on the supplied value. Returns false if the header field is not present or empty, and null if the field value is noticeably malformed.
Array
(
[scheme] => https
[host] => example.com
[path] => /foo/
)
public static HTTPHeader::Referrer_Policy(
string $string
): string|null|false-
$string
A string containing one or more headers, or a complete HTTP message.
Returns a directive. Returns false if the header field is not present or empty, and null if the field value is noticeably malformed.
public static HTTPHeader::Retry_After(
string $string
): \DateTimeImmutable|int|null|false-
$string
A string containing one or more headers, or a complete HTTP message.
Returns a DateTimeImmutable object, or a non-negative integer representing the delay in seconds. Returns false if the header field is not present or empty, and null if the field value is noticeably malformed.
public static HTTPHeader::RTT(
string $string = null
): array|null|false-
$string
A string containing one or more headers, or a complete HTTP message.
Returns a non-negative integer representing the approximate round trip time in milliseconds. Returns false if the header field is not present or empty, and null if the field value is noticeably malformed.
public static HTTPHeader::Save_Data(
string $string = null
): int|null|false-
$string
A string containing one or more headers, or a complete HTTP message.
Returns the integer 0 for falsey values, 1 for truthy values, or null if the value is indeterminate. Returns false if the header field is not present or empty, and null if the field value is noticeably malformed.
public static HTTPHeader::Sec_Fetch_Dest(
string $string = null
): string|null|false-
$string
A string containing one or more headers, or a complete HTTP message.
Returns a directive. Returns false if the header field is not present or empty, and null if the field value is noticeably malformed.
public static HTTPHeader::Sec_Fetch_Mode(
string $string = null
): string|null|false-
$string
A string containing one or more headers, or a complete HTTP message.
Returns a directive. Returns false if the header field is not present or empty, and null if the field value is noticeably malformed.
public static HTTPHeader::Sec_Fetch_Site(
string $string = null
): string|null|false-
$string
A string containing one or more headers, or a complete HTTP message.
Returns a directive. Returns false if the header field is not present or empty, and null if the field value is noticeably malformed.
public static HTTPHeader::Sec_Fetch_Storage_Access(
string $string = null
): string|null|false-
$string
A string containing one or more headers, or a complete HTTP message.
Returns a directive. Returns false if the header field is not present or empty, and null if the field value is noticeably malformed.
public static HTTPHeader::Sec_Fetch_User(
string $string = null
): ?bool-
$string
A string containing one or more headers, or a complete HTTP message.
Returns true if the value is "?1", or null otherwise.
public static HTTPHeader::Sec_GPC(
string $string = null
): ?bool-
$string
A string containing one or more headers, or a complete HTTP message.
Returns true if the value is "1", or null otherwise.
public static HTTPHeader::Sec_Purpose(
string $string = null
): string|null|false-
$string
A string containing one or more headers, or a complete HTTP message.
Returns a directive. Returns false if the header field is not present or empty, and null if the field value is noticeably malformed.
public static HTTPHeader::Server(
string $string
): array|null|false-
$string
A string containing one or more headers, or a complete HTTP message.
Returns an array of associative arrays containing the product, version and comment (if supplied). Returns false if the header field is not present or empty, and null if the field value is noticeably malformed.
Array
(
[0] => Array
(
[product] => Apache
[version] => 2.4.1
[comment] => Unix
)
)
public static HTTPHeader::Server_Timing(
string $string
): string|null|false-
$string
A string containing one or more headers, or a complete HTTP message.
Returns an array of associative arrays containing the metric name, description and duration (if supplied). Returns false if the header field is not present or empty, and null if the field value is noticeably malformed.
Array
(
[0] => Array
(
[name] => db
[dur] => 53
)
[1] => Array
(
[name] => cache
[desc] => Cache Read
[dur] => 23.2
)
)
public static HTTPHeader::Service_Worker_Navigation_Preload(
string $string = null
): string|false-
$string
A string containing one or more headers, or a complete HTTP message.
Returns a string. Returns false if the header field is not present or empty.
public static HTTPHeader::Set_Cookie(
string $string
): array|null|false-
$string
A string containing one or more headers, or a complete HTTP message.
Returns an array of arrays containing the cookie name and value, and an associative array of parameter values. Returns false if the header field is not present or empty, and null if the field value is noticeably malformed.
Array
(
[0] => Array
(
[0] => Session
[1] => 0ae5ab57925bcbee58917d552acb4cd4
)
[1] => Array
(
[Path] => /
[Domain] => example.com
[SameSite] =>
[Expires] => DateTimeImmutable Object
(
[date] => 2015-10-21 07:28:00.000000
[timezone_type] => 2
[timezone] => GMT
)
[Max-Age] => 20
[HttpOnly] => <true|false>
[Secure] => <true|false>
[Partitioned] => <true|false>
)
)
public static HTTPHeader::Set_Login(
string $string
): string|null|false-
$string
A string containing one or more headers, or a complete HTTP message.
Returns the string "logged-in", the string "logged-out", or null if the value is indeterminate. Returns false if the header field is not present or empty.
public static HTTPHeader::SourceMap(
string $string
): string|false-
$string
A string containing one or more headers, or a complete HTTP message.
Returns a string. Returns false if the header field is not present or empty.
public static HTTPHeader::Strict_Transport_Security(
string $string
): array|null|false-
$string
A string containing one or more headers, or a complete HTTP message.
Returns an associative array of parameter values. Returns false if the header field is not present or empty, and null if the field value is noticeably malformed.
Array
(
[max-age] => 63072000
[includeSubDomains] => <true|false>
[preload] => <true|false>
)
public static HTTPHeader::TE(
string $string = null
): array|null|false-
$string
A string containing one or more headers, or a complete HTTP message.
Returns an array sorted by "q" value. Returns false if the header field is not present or empty, and null if the field value is noticeably malformed.
Array
(
[0] => trailers
[1] => gzip
[2] => deflate;q=0.5
)
public static HTTPHeader::Timing_Allow_Origin(
string $string
): string|array|null|false-
$string
A string containing one or more headers, or a complete HTTP message.
Returns the string "*", or an array containing the results of parse_url() on each of the supplied values. Returns false if the header field is not present or empty, and null if the field value is noticeably malformed.
Array
(
[0] => Array
(
[scheme] => https
[host] => mozilla.org
)
[1] => Array
(
[scheme] => http
[host] => example.com
)
)
public static HTTPHeader::Tk(
string $string
): string|null|false-
$string
A string containing one or more headers, or a complete HTTP message.
Returns one of the strings !, ?, G, N, T, C, P, D, U, or null if the value is indeterminate. Returns false if the header field is not present or empty.
public static HTTPHeader::Trailer(
string $string
): array|null|false-
$string
A string containing one or more headers, or a complete HTTP message.
Returns an array of field names. Returns false if the header field is not present or empty, and null if the field value is noticeably malformed.
Array
(
[0] => Expires
[1] => Date
)
public static HTTPHeader::Transfer_Encoding(
string $string
): array|null|false-
$string
A string containing one or more headers, or a complete HTTP message.
Returns an array of encoding formats in the order in which they were applied. Returns false if the header field is not present or empty, and null if the field value is noticeably malformed.
Array
(
[0] => gzip
[1] => chunked
)
public static HTTPHeader::Upgrade(
string $string = null
): array|null|false-
$string
A string containing one or more headers, or a complete HTTP message.
Returns an array of protocols in order of preference. Returns false if the header field is not present or empty, and null if the field value is noticeably malformed.
Array
(
[0] => HTTP/2
[1] => HTTP/1.1
)
public static HTTPHeader::Upgrade_Insecure_Requests(
string $string = null
): int|null|false-
$string
A string containing one or more headers, or a complete HTTP message.
Returns the integer 0, 1, or null if the value is indeterminate. Returns false if the header field is not present or empty.
public static HTTPHeader::User_Agent(
string $string = null
): array|null|false-
$string
A string containing one or more headers, or a complete HTTP message.
Returns an array of associative arrays containing the product, version and comment (if supplied). Returns false if the header field is not present or empty, and null if the field value is noticeably malformed.
Array
(
[0] => Array
(
[product] => Mozilla
[version] => 5.0
[comment] => Windows NT 10.0; Win64; x64; rv:109.0
)
[1] => Array
(
[product] => Gecko
[version] => 20100101
)
[2] => Array
(
[product] => Firefox
[version] => 115.0
)
)
public static HTTPHeader::Vary(
string $string
): string|array|null|false-
$string
A string containing one or more headers, or a complete HTTP message.
Returns the string "*", or an array of field names. Returns false if the header field is not present or empty, and null if the field value is noticeably malformed.
Array
(
[0] => Cookie
[1] => Save-Data
)
public static HTTPHeader::Via(
string $string = null
): array|null|false-
$string
A string containing one or more headers, or a complete HTTP message.
Returns an array of associative arrays containing the details supplied by each proxy. Returns false if the header field is not present or empty, and null if the field value is noticeably malformed.
Array
(
[0] => Array
(
[protocol] => HTTP
[version] => 1.0
[pseudonym] => foo
)
[1] => Array
(
[version] => 1.1
[pseudonym] => bar
)
[2] => Array
(
[version] => 1.1
[pseudonym] => example.com
[port] => 80
[comment] => this is a comment
)
)
public static HTTPHeader::Want_Digest(
string $string = null
): array|null|false-
$string
A string containing one or more headers, or a complete HTTP message.
Returns an array sorted by "q" value. Returns false if the header field is not present or empty, and null if the field value is noticeably malformed.
Array
(
[0] => sha-256;q=1
[1] => SHA-512;q=0.3
[2] => md5;q=0
)
public static HTTPHeader::WWW_Authenticate(
string $string
): array|null|false-
$string
A string containing one or more headers, or a complete HTTP message.
Returns an array of arrays containing the authentication type and parameters. Returns false if the header field is not present or empty, and null if the field value is noticeably malformed.
Array
(
[0] => Array
(
[0] => scheme1
[3] => realm="foo"
[4] => param1=token1
[5] => param2=token2
)
[1] => Array
(
[0] => scheme2
[1] => token68
[2] => realm="bar"
)
[2] => Array
(
[0] => scheme3
)
)
public static HTTPHeader::X_Content_Type_Options(
string $string
): string|null|false-
$string
A string containing one or more headers, or a complete HTTP message.
Returns the string "nosniff", or null if the value is indeterminate. Returns false if the header field is not present or empty.
public static HTTPHeader::X_Frame_Options(
string $string
): string|null|false-
$string
A string containing one or more headers, or a complete HTTP message.
Returns a directive. Returns false if the header field is not present or empty, and null if the field value is noticeably malformed.