使用 32 位元 (X86) 的 PHP 寫入 4GB 的虛擬檔案
如果您想寫入更大的檔案 (>4GB),請使用 64 位元 (X64) 的 PHP。
此檔案於 0.0041329860687256 秒內建立完成
CreatFileDummy('data_test.txt',4294967296);
FUNCTION CreatFileDummy($file_name,$size) {
// 32 位元最大檔案大小為 4,294,967,296 位元組
$f = fopen($file_name, 'wb');
if($size >= 1000000000) {
$z = ($size / 1000000000);
if (is_float($z)) {
$z = round($z,0);
fseek($f, ( $size - ($z * 1000000000) -1 ), SEEK_END);
fwrite($f, "\0");
}
while(--$z > -1) {
fseek($f, 999999999, SEEK_END);
fwrite($f, "\0");
}
}
else {
fseek($f, $size - 1, SEEK_END);
fwrite($f, "\0");
}
fclose($f);
Return true;
}
Synx