PHP头条
热点:

php写入、删除与复制文件的方法


   本文实例讲述了php写入、删除与复制文件的方法。分享给大家供大家参考。具体如下:

  1. 写入:

  ?

1

2

3

4

5

6

7

<?php

$filename = "Test//file.txt";

$file = fopen($filename, "w"); //以写模式打开文件

fwrite($file, "Hello, world!/n"); //写入第一行

fwrite($file, "This is a test!/n"); //写入第二行

fclose($file); //关闭文件

?>

  2. 删除:

  ?

1

2

3

4

<?php

$filename = "Test//file.txt";

unlink($filename); //删除文件

?>

  3.复制:

  ?

1

2

3

4

5

<?php

$filename1 = "Test//file.txt";

$filename2 = "Test//file.bak";

copy($filename1, $filename2); //复制文件

?>

  希望本文所述对大家的php程序设计有所帮助。

www.phpzy.comtrue/php/27136.htmlTechArticlephp写入、删除与复制文件的方法 本文实例讲述了php写入、删除与复制文件的方法。分享给大家供大家参考。具体如下: 1. 写入: ? 1 2 3 4 5 6 7 ?php $filename = Test//file.txt; $file = fopen($filen...

相关文章

    暂无相关文章

PHP之友评论

今天推荐