xref: /PHP-7.2/ext/spl/tests/fileobject_001.phpt (revision 610c7fbe)
1--TEST--
2SPL: SplFileObject::seek'ing
3--FILE--
4<?php
5
6$o = new SplFileObject(dirname(__FILE__) . '/fileobject_001a.txt');
7
8var_dump($o->key());
9var_dump($o->current());
10$o->setFlags(SplFileObject::DROP_NEW_LINE);
11var_dump($o->key());
12var_dump($o->current());
13var_dump($o->key());
14$o->next();
15var_dump($o->key());
16var_dump($o->current());
17var_dump($o->key());
18$o->rewind();
19var_dump($o->key());
20var_dump($o->current());
21var_dump($o->key());
22$o->seek(4);
23var_dump($o->key());
24var_dump($o->current());
25var_dump($o->key());
26
27echo "===A===\n";
28foreach($o as $n => $l)
29{
30	var_dump($n, $l);
31}
32
33echo "===B===\n";
34$o = new SplFileObject(dirname(__FILE__) . '/fileobject_001b.txt');
35$o->setFlags(SplFileObject::DROP_NEW_LINE);
36foreach($o as $n => $l)
37{
38	var_dump($n, $l);
39}
40
41?>
42===DONE===
43--EXPECT--
44int(0)
45string(2) "0
46"
47int(0)
48string(2) "0
49"
50int(0)
51int(1)
52string(1) "1"
53int(1)
54int(0)
55string(1) "0"
56int(0)
57int(4)
58string(1) "4"
59int(4)
60===A===
61int(0)
62string(1) "0"
63int(1)
64string(1) "1"
65int(2)
66string(1) "2"
67int(3)
68string(1) "3"
69int(4)
70string(1) "4"
71int(5)
72string(1) "5"
73int(6)
74string(0) ""
75===B===
76int(0)
77string(1) "0"
78int(1)
79string(1) "1"
80int(2)
81string(1) "2"
82int(3)
83string(1) "3"
84int(4)
85string(1) "4"
86int(5)
87string(1) "5"
88===DONE===
89