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
    • 570
    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 :

    copy(used in PHP 4, PHP 5)

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

    Syntax:

      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:

    <?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)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: