tWithHeaders
MMO\core\classes · 1 symbol · generated 5 Oct 2026
tWithHeaders
tWithHeaders.php:22Generic, case-insensitive HTTP-header storage, implementing the read/write parts of PSR-7's MessageInterface (getHeaders/hasHeader/getHeader/getHeaderLine) plus a handful of convenience getters/setters on top.
- Namespace
MMO\core\classes- See
setHeader/hasHeader/getHeadercall for the same header name (in any casing) resolves back to that same stored entry.- Todo
- move into aMessage
Index
| headers | ||
| ikeys | ||
| addHeader($name, $value) | Append a value to a header, keeping any value(s) already set (as opposed to setHeader, which replaces). | |
| getCharset() | ||
| getContentExtension() | ||
| getContentType($single) | ||
| getHeader($name) | Retrieves a message header value by the given case-insensitive name. | |
| getHeaderLine($name) | Retrieves a comma-separated string of the values for a single header. | |
| getHeaders() | Retrieves all message header values. | |
| getOrigin() | Get origin of the request by looking at 'Origin', then 'Referer', then 'Sender' in the request's headers. | |
| getUserAgent() | ||
| hasHeader($name) | Checks if a header exists by the given case-insensitive name. | |
| isHTML() | ||
| isIe() | ||
| isIphone() | ||
| isJSON() | ||
| isMac() | ||
| isMobile() | ||
| isWindows() | ||
| setCacheControl($cache, $pragma) | Set the Cache-Control header (and, optionally, the legacy Pragma header alongside it). | |
| setContentType($type, $charset) | Set the Content-Type header, appending a charset parameter (unless $charset is null/empty). | |
| setExpires($time) | Set the Expires header from a unix timestamp, formatted as an RFC 7231 HTTP-date. | |
| setHeader($name, $value) | Set header, replacing any previous value(s) for the same (case-insensitively matched) header name. | |
| unsetHeader($name) | Remove a header entirely. |
Properties2
headers
ikeys
Methods22
addHeader($name, $value)
tWithHeaders.php:166Append a value to a header, keeping any value(s) already set (as opposed to setHeader, which replaces).
| $name | string | |
| $value | array | string | a plain string is appended as a single new value (NOT split on ',', unlike setHeader) |
| returns | self |
getCharset()
tWithHeaders.php:55getContentExtension()
tWithHeaders.php:63| returns | null | string | the file extension conventionally associated with the Content-Type header (e.g. 'html', 'json') |
getContentType($single)
tWithHeaders.php:47| $single = true | bool | if true, return only the media type (e.g. 'text/html'); if false, every parameter too |
| returns | array | string |
getHeader($name)
tWithHeaders.php:254Retrieves a message header value by the given case-insensitive name.
| $name | string | Case-insensitive header field name. |
| returns | array | An array of string values as provided for the given header. If the header does not appear in the message, this method MUST return an empty array. |
getHeaderLine($name)
tWithHeaders.php:281Retrieves a comma-separated string of the values for a single header.
| $name | string | Case-insensitive header field name. |
| returns | string | A string of values as provided for the given header concatenated together using a comma. If the header does not appear in the message, this method MUST return an empty string. |
getHeaders()
tWithHeaders.php:218Retrieves all message header values.
| returns | array | Returns an associative array of the message's headers. Each key MUST be a header name, and each value MUST be an array of strings for that header. |
getOrigin()
tWithHeaders.php:35Get origin of the request by looking at 'Origin', then 'Referer', then 'Sender' in the request's headers.
| returns | string | '' if none of those headers are set |
getUserAgent()
tWithHeaders.php:70hasHeader($name)
tWithHeaders.php:231Checks if a header exists by the given case-insensitive name.
| $name | string | Case-insensitive header field name. |
| returns | bool | Returns true if any header names match the given header name using a case-insensitive string comparison. Returns false if no matching header name is found in the message. |
isHTML()
tWithHeaders.php:119| returns | bool | true if getContentExtension is 'html' |
isIe()
tWithHeaders.php:84| returns | bool | true if the User-Agent looks like Internet Explorer |
isIphone()
tWithHeaders.php:77| returns | bool | true if the User-Agent looks like mobile Safari on iPhone |
isJSON()
tWithHeaders.php:126| returns | bool | true if getContentExtension is 'json' |
isMac()
tWithHeaders.php:98| returns | bool | true if the User-Agent mentions macOS |
isMobile()
tWithHeaders.php:105| returns | bool | true if the User-Agent looks like a mobile device/browser |
isWindows()
tWithHeaders.php:91| returns | bool | true if the User-Agent mentions Windows |
setCacheControl($cache, $pragma)
tWithHeaders.php:305Set the Cache-Control header (and, optionally, the legacy Pragma header alongside it).
| $cache | cache method 'public', 'private', 'no-cache', 'no-store' | |
| $pragma = null | if given, also sets the Pragma header (e.g. 'no-cache', for HTTP/1.0 clients) | |
| returns | self |
setContentType($type, $charset)
tWithHeaders.php:293Set the Content-Type header, appending a charset parameter (unless $charset is null/empty).
| $type | string | the media type, e.g. 'text/html' or one of the framework's MIME_* constants |
| $charset = 'utf-8' | null | string | appended as ;charset=$charset; pass null/'' to omit it entirely |
| returns | self |
setExpires($time)
tWithHeaders.php:317Set the Expires header from a unix timestamp, formatted as an RFC 7231 HTTP-date.
| $time | null | int | a unix timestamp; 0 (or any past time) tells clients/caches the response is already stale |
| returns | self |
setHeader($name, $value)
tWithHeaders.php:143Set header, replacing any previous value(s) for the same (case-insensitively matched) header name.
| $name | string | |
| $value | array | string | if a string, it is split on ',' into the multiple values PSR-7 expects a header to hold (e.g. 'a,b' becomes ['a', 'b']) -- pass an array (even a single-element one, e.g. [$value]) if $value may itself legitimately contain a comma that must NOT be split (an HTTP-date value like 'Thu, 01 Jan ...' is the classic example -- see setExpires) |
| returns | self |
unsetHeader($name)
tWithHeaders.php:179Remove a header entirely.