PHP可以使用file_get_contents()
函数读取文件内容:
$filename = "example.txt";
$content = file_get_contents($filename);
echo $content;
使用file_put_contents()
函数写入文件:
$filename = "example.txt";
$content = "This is some text.";
file_put_contents($filename, $content);
使用copy()
函数复制文件:
$original = "example.txt";
$copy = "example_copy.txt";
copy($original, $copy);
使用rename()
函数移动文件:
$original = "example.txt";
$new_location = "path/to/new/location/example.txt";
rename($original, $new_location);
使用unlink()
函数删除文件:
$filename = "example.txt";
unlink($filename);