How to replace 1024-1054 bytes of a large file with a by php

I don"t want to use the file_get_contents function because the file is too large

Php
Mar.28,2021

$fp = fopen('a.txt', 'r+');
fseek($fp, 1024);
fwrite($fp, str_repeat('a', 30));
fclose($fp);

use the SplFileObject class extended by SPL to handle large files

$oFile = new SplFileObject($filename,'w');

$oFile->fseek(1024,SEEK_SET);

$oFile->fwrite(str_repeat('a',30));

$oFile = null;
Menu