⊗ppPmFSFC 340 of 447 menu

Copying Files in PHP

The function copy allows you to copy a file. Its first parameter is the path to the file you want to copy, the second is the new file path where you want to place the copy. We can make a copy and place it next to the original, or put it in another folder. Let's make a simple copy:

For example, let's make a copy of a file, placing it in the same folder as the source file:

<?php copy('test.txt', 'copy.txt'); ?>

And now let's place our copy in the folder dir:

copy('test.txt', 'dir/copy.txt');

Let there be a file in the root of your site. Using a loop, place five copies of this file into the folder copy. Let the names of the copy files be their serial numbers.

byenru