PHP Velho Oeste 2024

http_match_etag

(PECL pecl_http >= 0.1.0)

http_match_etagETag を比較する

説明

bool http_match_etag ( string $etag [, bool $for_range = false ] )

指定された ETag を、クライアントの HTTP ヘッダ If-Match あるいは If-None-Match と比較します。

パラメータ

etag

比較する ETag

for_range

TRUE に設定すると、通常は HTTP の範囲を検証するために使用されるヘッダが チェックされます。

返り値

ETag が一致する場合やヘッダにアスタリスク ("*") が含まれる場合に TRUE、それ以外の場合に FALSE を返します。

参考

add a note add a note

User Contributed Notes 2 notes

up
1
php dot net at eoasys dot com
16 years ago
Regarding the 20071101 note of "root at mantoru dot de":

That solution got me started but didn't quite work for me. Apache (at least 2.x) applies an algorithm to the Last-Modified time. A solution that worked perfectly for me is at http://us3.php.net/manual/en/function.fileinode.php#78264.

Richard
up
1
root at mantoru dot de
16 years ago
An Apache-like ETag can be generated like this:

<?php
function etag($filename, $quote = true) {
    if (!
file_exists($filename) || !($info = stat($filename))) {
        return
false;
    }
   
$q = ($quote) ? '"' : '';
    return
sprintf("$q%x-%x-%x$q", $info['ino'], $info['size'], $info['mtime']);
}
?>
To Top