1--TEST--
2Test file function : variation - test various endings of a file
3--CREDITS--
4Dave Kelsey <d_kelsey@uk.ibm.com>
5--FILE--
6<?php
7echo "*** Testing file() : variation ***\n";
8$testfile = __DIR__."/fileVar9.txt";
9
10$contents = array(
11   "File ends on a single character\na",
12   "File ends on a new line\n",
13   "File ends on multiple newlines\n\n\n\n",
14   "File has\n\nmultiple lines and newlines\n\n",
15   "File has\r\nmultiple crlfs\n\r\n"
16   );
17
18@unlink($testfile);
19foreach ($contents as $content) {
20    $h = fopen($testfile, "w");
21    fwrite($h, $content);
22    fclose($h);
23    var_dump(file($testfile));
24    unlink($testfile);
25}
26
27echo "\n*** Done ***\n";
28?>
29--EXPECT--
30*** Testing file() : variation ***
31array(2) {
32  [0]=>
33  string(32) "File ends on a single character
34"
35  [1]=>
36  string(1) "a"
37}
38array(1) {
39  [0]=>
40  string(24) "File ends on a new line
41"
42}
43array(4) {
44  [0]=>
45  string(31) "File ends on multiple newlines
46"
47  [1]=>
48  string(1) "
49"
50  [2]=>
51  string(1) "
52"
53  [3]=>
54  string(1) "
55"
56}
57array(4) {
58  [0]=>
59  string(9) "File has
60"
61  [1]=>
62  string(1) "
63"
64  [2]=>
65  string(28) "multiple lines and newlines
66"
67  [3]=>
68  string(1) "
69"
70}
71array(3) {
72  [0]=>
73  string(10) "File has
74"
75  [1]=>
76  string(15) "multiple crlfs
77"
78  [2]=>
79  string(2) "
80"
81}
82
83*** Done ***
84