a7d319d82e78978001ace0a6bd2a62a24c885307
[mdref/mdref-http] / etag.md
1 # string http\Message\Body::etag()
2
3 Retrieve the ETag of the body.
4
5 ## Params:
6
7 None.
8
9 ## Returns:
10
11 * string, an Apache style ETag of inode, mtime and size in hex concatenated by hyphens if the message body stream is stat-able.
12 * string, a content hash (which algorithm is determined by INI http.etag.mode) if the stream is not stat-able.
13 * false, if http.etag.mode is not a known hash algorithm.
14
15 ## Example:
16
17 <?php
18 $temp = (new http\Message\Body)->etag();
19 $file = (new http\Message\Body(fopen(__FILE__,"r")))->etag();
20
21 ini_set("http.etag.mode", "bogus");
22 $fail = (new http\Message\Body)->etag();
23
24 var_dump(compact("temp", "file", "fail"));
25 ?>
26
27 Yields:
28
29 array(3) {
30 ["temp"]=>
31 string(8) "00000000"
32 ["file"]=>
33 string(20) "138043f-527b91d5-28c"
34 ["fail"]=>
35 bool(false)
36 }