Oihana PHP System

etagMatches.php

Table of Contents

Functions

etagMatches()  : bool
Tells whether an `If-None-Match` header value matches a given `ETag`.

Functions

etagMatches()

Tells whether an `If-None-Match` header value matches a given `ETag`.

etagMatches(string $header, string $etag) : bool

Implements the RFC 7232 §3.2 semantics used for If-None-Match:

  • * matches any current representation;
  • otherwise the header is a comma-separated list of entity tags, compared with the weak comparison function — the W/ prefix is ignored on both sides, so W/"x" and "x" are considered a match.
Parameters
$header : string

The raw If-None-Match header value.

$etag : string

The current ETag of the resource (as produced by computeETag()).

Tags
author

Marc Alcaraz (ekameleon)

since
1.0.0
example
etagMatches( '*'             , '"abc"' ) ; // true  (matches any representation)
etagMatches( '"abc", "def"'  , '"abc"' ) ; // true  (present in the list)
etagMatches( 'W/"abc"'       , '"abc"' ) ; // true  (weak comparison)
etagMatches( '"xyz"'         , '"abc"' ) ; // false (no match)
etagMatches( ''              , '"abc"' ) ; // false (no precondition)
Return values
bool

true when the precondition matches (the caller should answer 304 Not Modified).

On this page

Search results