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

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


<&#63;php
$filename = "Test//file.txt";
$file = fopen($filename, "w"); /
文章正文

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

1. 写入:

<?php 
$filename = "Test//file.txt"; 
$file = fopen($filename, "w"); //以写模式打开文件 
fwrite($file, "Hello, world!/n"); //写入第一行 
fwrite($file, "This is a test!/n"); //写入第二行 
fclose($file); //关闭文件 
?> 

2. 删除:

<?php 
$filename = "Test//file.txt"; 
unlink($filename); //删除文件 
?> 

3.复制:

<?php 
$filename1 = "Test//file.txt"; 
$filename2 = "Test//file.bak"; 
copy($filename1, $filename2); //复制文件 
?>

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


代码注释

作者:喵哥笔记

IDC笔记

学的不仅是技术,更是梦想!