The examples in this article describe how to write, delete and copy files in php. Share it with everyone for your reference. The details are as follows:
1. Write:
<?php $filename = "Test//file.txt"; $file = fopen($filename, "w"); //以写模式打开文件 fwrite($file, "Hello, world!/n"); //写入第一行 fwrite($file, "This is a test!/n"); //写入第二行 fclose($file); //关闭文件 ?>
2. Delete:
<?php $filename = "Test//file.txt"; unlink($filename); //删除文件 ?>
3. Copy:
<?php $filename1 = "Test//file.txt"; $filename2 = "Test//file.bak"; copy($filename1, $filename2); //复制文件 ?>
I hope this article will be helpful to everyone’s PHP programming design.