Optimizing memory usage and changing file contents with PHP
Posted
by
errata
on Stack Overflow
See other posts from Stack Overflow
or by errata
Published on 2012-10-30T21:41:09Z
Indexed on
2012/10/30
23:01 UTC
Read the original article
Hit count: 176
In a function like this
function download($file_source, $file_target) {
$rh = fopen($file_source, 'rb');
$wh = fopen($file_target, 'wb');
if (!$rh || !$wh) {
return false;
}
while (!feof($rh)) {
if (fwrite($wh, fread($rh, 1024)) === FALSE) {
return false;
}
}
fclose($rh);
fclose($wh);
return true;
}
what is the best way to rewrite last few bytes of a file with my custom string?
Thanks!
© Stack Overflow or respective owner