1--TEST--
2testing stream_get_meta_data() "eof" field for a file stream
3--FILE--
4<?php
5
6$filename = __FILE__ . '.tmp';
7
8$fp = fopen($filename, "w+");
9
10echo "Write some data to the file:\n";
11$i = 0;
12while ($i++ < 20) {
13    fwrite($fp, "a line of data\n");
14}
15
16var_dump(stream_get_meta_data($fp));
17
18//seek to start of file
19rewind($fp);
20
21echo "\n\nRead entire file:\n";
22while(!feof($fp)) {
23    fread($fp, 1);
24}
25
26var_dump(stream_get_meta_data($fp));
27
28fclose($fp);
29
30unlink($filename);
31
32?>
33--EXPECTF--
34Write some data to the file:
35array(9) {
36  ["timed_out"]=>
37  bool(false)
38  ["blocked"]=>
39  bool(true)
40  ["eof"]=>
41  bool(false)
42  ["wrapper_type"]=>
43  string(9) "plainfile"
44  ["stream_type"]=>
45  string(5) "STDIO"
46  ["mode"]=>
47  string(2) "w+"
48  ["unread_bytes"]=>
49  int(0)
50  ["seekable"]=>
51  bool(true)
52  ["uri"]=>
53  string(%i) "%s"
54}
55
56
57Read entire file:
58array(9) {
59  ["timed_out"]=>
60  bool(false)
61  ["blocked"]=>
62  bool(true)
63  ["eof"]=>
64  bool(true)
65  ["wrapper_type"]=>
66  string(9) "plainfile"
67  ["stream_type"]=>
68  string(5) "STDIO"
69  ["mode"]=>
70  string(2) "w+"
71  ["unread_bytes"]=>
72  int(0)
73  ["seekable"]=>
74  bool(true)
75  ["uri"]=>
76  string(%i) "%s"
77}
78