Article From:https://segmentfault.com/q/1010000015620479
Question:

Do not want to use the file_get_contents function, because the file is too large.

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

Answer 1:

Using SPL extended SplFileObject class to process large files

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

$oFile->fseek(1024,SEEK_SET);

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

$oFile = null;

Leave a Reply

Your email address will not be published. Required fields are marked *