]> granicus.if.org Git - php/blob
e26a8d7aea
[php] /
1 --TEST--
2 SPL: SplFileObject truncate tests
3 --CREDITS--
4 Mark Ammann
5 #Hackday Webtuesday 2008-05-24
6 --FILE--
7 <?php
8
9 set_include_path(dirname(__DIR__));
10
11 $path = __DIR__.DIRECTORY_SEPARATOR.'fileobject_005.txt';
12 touch($path);
13
14 $fo = new SplFileObject('tests'.DIRECTORY_SEPARATOR.'fileobject_005.txt', 'w+', true);
15 $fo->fwrite("blahlubba");
16 var_dump($fo->ftruncate(4));
17
18 $fo->rewind();
19 var_dump($fo->fgets());
20
21 $fo->rewind();
22 $fo->fwrite("blahlubba");
23
24 ?>
25 --CLEAN--
26 <?php
27 $path = __DIR__.DIRECTORY_SEPARATOR.'fileobject_005.txt';
28 unlink($path);
29 ?>
30 --EXPECTF--
31 bool(true)
32 string(4) "blah"