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