1. PHP Partial file Operation function
(1) fopen Open File function
fopen ( path and file name, open mode );
(2) fread Read file contents
fread ( open file, end position );
(3) filesize Read file size, bytes in units of measure
filesize ( path and file name );
(4) fwrite Write file contents
fwrite ( path and file name, write content );
(5) fclose Close Open File
Close ( path and file name );
Cases:
<?php
$arr = Array ("News title 222", "News Content 222"), Array ("News title 333", "News content 3333"));
foreach ($arr as $id = = $value) {
$fp = fopen ("tmp.htm", "R");
str = fread ($fp, FileSize ("tmp.htm"));
Fclose ($FP);
$title = $value [0];
$content = $value [1];
$path = $id. ". HTML ";
$str = Str_replace ("{title}", $title, $STR);
$str = Str_replace ("{content}", $content, $STR);
$NFP = fopen ($path, "w");
Fwrite ($NFP, $STR);
Fclose ($NFP);
}
? >
2,unlink () rmdir () Delete function
Unlink () Delete file function
Unlink (path and file name)
RmDir () Delete a directory function
RmDir (path and directory name)