cod*_*ict 10
define('SIZE',100); // size of the file to be created.
$fp = fopen('somefile.txt', 'w'); // open in write mode.
fseek($fp, SIZE-1,SEEK_CUR); // seek to SIZE-1
fwrite($fp,'a'); // write a dummy char at SIZE position
fclose($fp); // close the file.
Run Code Online (Sandbox Code Playgroud)
执行时:
$ php a.php
$ wc somefile.txt
0 1 100 somefile.txt
$
Run Code Online (Sandbox Code Playgroud)