您可以使用
fopen
和
fseek
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.
执行时:
$PHP a.PHP $wc somefile.txt 0 1 100 somefile.txt $