computeETag.php
Table of Contents
Functions
- computeETag() : string
- Computes an HTTP entity tag (`ETag`) validator for a file.
Functions
computeETag()
Computes an HTTP entity tag (`ETag`) validator for a file.
computeETag(string $file[, bool $weak = false ][, bool $hashContent = false ]) : string
By default the tag is derived from the file metadata (mtime-size, in
hexadecimal) so no content read is required — this keeps large-file streaming
cheap. Pass $hashContent = true to build an exact, byte-level tag from
md5_file() instead (reads the whole file).
The returned value is a quoted opaque tag, prefixed with W/ when $weak is true.
Parameters
- $file : string
-
Absolute path of the file (must exist).
- $weak : bool = false
-
Emit a weak validator (
W/"...") instead of a strong one. - $hashContent : bool = false
-
Derive the tag from the file content (
md5_file()) instead of its metadata.
Tags
Return values
string —The ETag value, e.g. "18f-3e8" or W/"18f-3e8".