Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • PHP Copy Files

    • 0
    • 1
    • 1
    • 2
    • 0
    • 0
    • 0
    • 0
    • 582
    Comment on it

    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 :

    1. copy(used in PHP 4, PHP 5)

    It takes two parameters as input:
    1. Destination path
    2. Source Path

    Syntax:

    1. copy (string $source, string $destination);

    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:

    1. <?php
    2. $source_file ='sourcefile.txt';
    3. $destination_file = 'destination.txt.bak';
    4. // Will copy source_file to destination_file
    5. // overwritting in destination if necessary
    6. if (!copy($source_file,
    7. $destination_file)) {
    8. echo "failed to copy $file...\n"; } ?>

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Reset Password
Fill out the form below and reset your password: