over 9 years ago
How to open and read PHP files have been discussed in previous blog:
http://findnerd.com/list/view/How-to-open-and-read-files-with-PHP/3157/
Now,we will discuss about copying a php file.
In php,we can Copy files from source to destination.
Function used :
It takes two parameters as input:
1. Destination path
2. Source Path
Syntax:
NOTE: If the destination file exists it will be overwritten.
It returns true on success and false on failure.
Can be explained with an example:
- <?php
- $source_file ='sourcefile.txt';
- $destination_file = 'destination.txt.bak';
- // Will copy source_file to destination_file
- // overwritting in destination if necessary
- if (!copy($source_file,
- $destination_file)) {
- echo "failed to copy $file...\n"; } ?>
<?php $source_file ='sourcefile.txt'; $destination_file = 'destination.txt.bak'; // Will copy source_file to destination_file // overwritting in destination if necessary if (!copy($source_file, $destination_file)) { echo "failed to copy $file...\n"; } ?>
0 Comment(s)