php move, copy and delete files

When we deal with files every day, we can delete files, rename files, or copy files.

In this section, we will explain some of the most commonly used operations in our daily lives.

Let’s talk about renaming first. The renaming function is:

Rename file

bool rename($old name,$new name);

This function returns a bool value to change the old name to the new name.

We open the directory and we can see the effect. You will find that the specified file is copied to the target path.

Copy files

Copying files is equivalent to cloning technology, cloning an original thing into a new thing. The two look exactly the same.

bool copy(source file, target file)

Function: Copy the source file with the specified path to the location of the target file.

Let’s play it through experiments and code:

Summary:
You will find that there is an extra file through the above example.

Delete file

Deleting a file means deleting a file in the specified path, but this deletion is direct deletion. If you are using a Windows computer, you cannot see this file in the Recycle Bin.

You will only find that this file has disappeared.

bool unlink(file with specified path)

Continuing Learning
||
submit Reset Code
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!