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 ["wrapper_type"]=> 37 string(9) "plainfile" 38 ["stream_type"]=> 39 string(5) "STDIO" 40 ["mode"]=> 41 string(2) "w+" 42 ["unread_bytes"]=> 43 int(0) 44 ["seekable"]=> 45 bool(true) 46 ["uri"]=> 47 string(%i) "%s" 48 ["timed_out"]=> 49 bool(false) 50 ["blocked"]=> 51 bool(true) 52 ["eof"]=> 53 bool(false) 54} 55 56 57Read entire file: 58array(9) { 59 ["wrapper_type"]=> 60 string(9) "plainfile" 61 ["stream_type"]=> 62 string(5) "STDIO" 63 ["mode"]=> 64 string(2) "w+" 65 ["unread_bytes"]=> 66 int(0) 67 ["seekable"]=> 68 bool(true) 69 ["uri"]=> 70 string(%i) "%s" 71 ["timed_out"]=> 72 bool(false) 73 ["blocked"]=> 74 bool(true) 75 ["eof"]=> 76 bool(true) 77} 78