Automattic\WooCommerce\Vendor\Detection

MobileDetect::getHttpHeader()publicWC 1.0

Retrieves a particular header. If it doesn't exist, no exception/error is caused. Simply null is returned.

Метод класса: MobileDetect{}

Хуков нет.

Возвращает

Строку|null. The value of the header.

Использование

$MobileDetect = new MobileDetect();
$MobileDetect->getHttpHeader( $header ): ?string;
$header(строка) (обязательный)
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() WC 9.6.0

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;
}