Annotation of embedaddon/php/ext/standard/tests/file/file_variation7.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: file() on a file with blank lines
3: --FILE--
4: <?php
5:
6: $filepath = __FILE__ . ".tmp";
7: $fd = fopen($filepath, "w+");
8: fwrite($fd, "Line 1\n\n \n \n\Line 3");
9: fclose($fd);
10:
11: echo "file():\n";
12: var_dump(file($filepath));
13:
14: echo "\nfile() with FILE_IGNORE_NEW_LINES:\n";
15: var_dump(file($filepath, FILE_IGNORE_NEW_LINES));
16:
17: echo "\nfile() with FILE_SKIP_EMPTY_LINES:\n";
18: var_dump(file($filepath, FILE_SKIP_EMPTY_LINES));
19:
20: echo "\nfile() with FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES:\n";
21: var_dump(file($filepath, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES));
22:
23: unlink($filepath);
24:
25: ?>
26: --EXPECT--
27: file():
28: array(5) {
29: [0]=>
30: string(7) "Line 1
31: "
32: [1]=>
33: string(1) "
34: "
35: [2]=>
36: string(2) "
37: "
38: [3]=>
39: string(3) "
40: "
41: [4]=>
42: string(7) "\Line 3"
43: }
44:
45: file() with FILE_IGNORE_NEW_LINES:
46: array(5) {
47: [0]=>
48: string(6) "Line 1"
49: [1]=>
50: string(0) ""
51: [2]=>
52: string(1) " "
53: [3]=>
54: string(2) " "
55: [4]=>
56: string(7) "\Line 3"
57: }
58:
59: file() with FILE_SKIP_EMPTY_LINES:
60: array(5) {
61: [0]=>
62: string(7) "Line 1
63: "
64: [1]=>
65: string(1) "
66: "
67: [2]=>
68: string(2) "
69: "
70: [3]=>
71: string(3) "
72: "
73: [4]=>
74: string(7) "\Line 3"
75: }
76:
77: file() with FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES:
78: array(4) {
79: [0]=>
80: string(6) "Line 1"
81: [1]=>
82: string(1) " "
83: [2]=>
84: string(2) " "
85: [3]=>
86: string(7) "\Line 3"
87: }
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>