1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
|
--TEST--
SplFileObject verify interactions between seeking, getting the key and fgets
--FILE--
<?php
$file = new SplTempFileObject();
for ($i = 0; $i < 100; $i++) {
$file->fwrite("Foo $i\n");
}
$file->seek(50);
var_dump(
['line' => $file->key(), 'contents' => trim($file->fgets())],
['line' => $file->key(), 'contents' => trim($file->fgets())],
['line' => $file->key(), 'contents' => trim($file->fgets())],
);
?>
--EXPECT--
array(2) {
["line"]=>
int(50)
["contents"]=>
string(6) "Foo 50"
}
array(2) {
["line"]=>
int(51)
["contents"]=>
string(6) "Foo 51"
}
array(2) {
["line"]=>
int(52)
["contents"]=>
string(6) "Foo 52"
}
|