PHP copy(), rename() and unlink() functions

 PHP copy(), rename() and unlink() file handling

In this php tutorial we will learn how use copy() function, rename() function and unlink() function with php example.

PHP File handling functions :

  • copy() – used to copy a file.
  • rename() – used to rename a file.
  • unlink() – used to delete a file.

PHP copy() Function

The copy() function is used to copy a file.

copy() function syntax


copy(“source filename”, “destination filename”);


copy() function example

PHP rename() Function

The rename() function is used to rename a file name.

rename() function syntax


rename(“old filename”,”new filename”);


rename() function example

PHP unlink() Function

How to Delete a file in PHP.

The unlink() function is used to delete a file.

unlink() function syntax




unlink() function example


(Visited 12 times, 1 visits today)

Leave a Reply

Your email address will not be published. Required fields are marked *

Captcha *