Automattic\WooCommerce\Vendor\Detection
MobileDetect::getHttpHeader
Retrieves a particular header. If it doesn't exist, no exception/error is caused. Simply null is returned.
Method of the class: MobileDetect{}
No Hooks.
Returns
String|null. The value of the header.
Usage
$MobileDetect = new MobileDetect(); $MobileDetect->getHttpHeader( $header ): ?string;
- $header(string) (required)
- The name of the header to retrieve. Can be HTTP compliant such as "User-Agent" or "X-Device-User-Agent" or can be php-esque with the all-caps, HTTP_ prefixed, underscore separated awesomeness.
MobileDetect::getHttpHeader() MobileDetect::getHttpHeader code WC 10.6.2
public function getHttpHeader(string $header): ?string
{
// are we using PHP-flavored headers?
if (strpos($header, '_') === false) {
$header = str_replace('-', '_', $header);
$header = strtoupper($header);
}
// test the alternate, too
$altHeader = 'HTTP_' . $header;
//Test both the regular and the HTTP_ prefix
if (isset($this->httpHeaders[$header])) {
return $this->httpHeaders[$header];
} elseif (isset($this->httpHeaders[$altHeader])) {
return $this->httpHeaders[$altHeader];
}
return null;
}