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

<?php

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

?>

copy() function example


PHP rename() Function

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

rename() function syntax

<?php

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

<?php

unlink(“filename”);

?>

unlink() function example

 

Leave a Reply

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

9 + 2 =


You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">