1--TEST--
2SPL: SplFileObject::fgetc
3--FILE--
4<?php
5
6function test($name)
7{
8    echo "===$name===\n";
9
10    $o = new SplFileObject(__DIR__ . '/' . $name);
11
12    var_dump($o->key());
13    while(($c = $o->fgetc()) !== false)
14    {
15        // Kinda ugly but works around new lines mess
16        if ($c === "\r") {
17            continue;
18        }
19        var_dump($o->key(), $c, $o->eof());
20    }
21    echo "===EOF?===\n";
22    var_dump($o->eof());
23    var_dump($o->key());
24    var_dump($o->eof());
25}
26
27test('fileobject_001a.txt');
28test('fileobject_001b.txt');
29
30?>
31--EXPECT--
32===fileobject_001a.txt===
33int(0)
34int(0)
35string(1) "0"
36bool(false)
37int(1)
38string(1) "
39"
40bool(false)
41int(1)
42string(1) "1"
43bool(false)
44int(2)
45string(1) "
46"
47bool(false)
48int(2)
49string(1) "2"
50bool(false)
51int(3)
52string(1) "
53"
54bool(false)
55int(3)
56string(1) "3"
57bool(false)
58int(4)
59string(1) "
60"
61bool(false)
62int(4)
63string(1) "4"
64bool(false)
65int(5)
66string(1) "
67"
68bool(false)
69int(5)
70string(1) "5"
71bool(false)
72int(6)
73string(1) "
74"
75bool(false)
76===EOF?===
77bool(true)
78int(6)
79bool(true)
80===fileobject_001b.txt===
81int(0)
82int(0)
83string(1) "0"
84bool(false)
85int(1)
86string(1) "
87"
88bool(false)
89int(1)
90string(1) "1"
91bool(false)
92int(2)
93string(1) "
94"
95bool(false)
96int(2)
97string(1) "2"
98bool(false)
99int(3)
100string(1) "
101"
102bool(false)
103int(3)
104string(1) "3"
105bool(false)
106int(4)
107string(1) "
108"
109bool(false)
110int(4)
111string(1) "4"
112bool(false)
113int(5)
114string(1) "
115"
116bool(false)
117int(5)
118string(1) "5"
119bool(false)
120===EOF?===
121bool(true)
122int(5)
123bool(true)
124