php综合应用目录文件操作函数解题
1、先打开此文件用fopen函数:<?php $file_path=fopen("file1.txt","a");
2、读取该文件的内容用fread函数,$content=fread($file_path,filesize("file1.txt"));
3、写入6行字符串用fwrite函数: 因为同样的内容,所以考虑用for循环: for($i=0;$i<6;$i++){ fwr足毂忍珩ite($file_path,"\r\n"."I love you"."\r\n");}
4、因为要拷贝到e盘根目录用copy函数: $file_path2="e:/file2.txt"; copy("file1.txt",$file_path2);
5、保存后运行,你会发现文件写入和拷贝都正确,如图:
