Home >Backend Development >PHP Tutorial >How to write, delete and copy files in PHP, _PHP tutorial

How to write, delete and copy files in PHP, _PHP tutorial

WBOY
WBOYOriginal
2016-07-13 09:49:33819browse

How to write, delete and copy files in php,

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:

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

2. Delete:

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

3. Copy:

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

I hope this article will be helpful to everyone’s PHP programming design.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/1019439.htmlTechArticleHow to write, delete and copy files in PHP. This article explains how to write, delete and copy files in PHP. method. Share it with everyone for your reference. The details are as follows: 1. Write: php $f...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn