<html> <head> <meta charset="utf-8"> </head> <body> <?php //设置路径 $path1="test1.txt"; $path2="test2.txt"; $path3="test3.txt"; //打开文件 $flag2=fopen($path2,"r"); $flag3=fopen($path3,"r"); //删除文件 //格式 unlink(文件路径); $flag_1=unlink($path1); if($flag_1){ echo "删除文件成功"."<br>"; } else { echo "删除文件失败"."<br>"; } //读取每个文件的内容 echo "文件test2.txt的内容是:".fgets($flag2)."<br>"; echo "文件test3.txt的内容是:".fgets($flag3)."<br>"; fclose($flag2); fclose($flag3); //复制文件 //格式 copy(源文件路径,目标文件路径) $flag_2=copy($path2,$path3); if($flag_2){ echo "文件复制成功"."<br>"; $flag3=fopen($path3,"r"); echo "文件test3.txt的内容是:".fgets($flag3)."<br>"; } else { echo "文件复制失败"."<br>"; } fclose($flag3); //重命名文件 //格式 rename(old name,new name) $flag_3=rename($path3,"test4.txt"); if($flag_3){ echo "重命名成功"."<br>"; } else { echo "重命名失败"."<br>"; } ?> </body> </html>