php创建给定大小的文件
发布时间:2020-05-25 10:28:02 所属栏目:PHP 来源:互联网
导读:如何在 PHP中创建具有给定大小的文件(无论内容)? 我必须创建一个大于1GB的文件.最大4-10GB 您可以使用 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
|
如何在 PHP中创建具有给定大小的文件(无论内容)? 我必须创建一个大于1GB的文件.最大4-10GB 您可以使用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 $ (编辑:安卓应用网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
