PHP copy() function

This function is used to copy a file. It returns a boolean value.

Syntax

copy( source file, destination file);

It returns TRUE, if file successfully copied to the destination file. If the destination file already exist, then it will overwrite the content.

Example

<?php
    if(copy('Source_file.txt', 'destination_file.txt')){
        echo 'file successfully copied';
    }
    else {
        echo 'File copied unsuccessfully';
    }
?>		

Output :

File copied unsuccessfully



Related PHP Functions

PHP array_reverse() function
PHP array_diff() function
PHP array_key_exists() function
PHP array_push() function
PHP array_search() function
PHP class_exists() function
PHP curl_setopt() function
PHP die() function
PHP dirname() function
PHP each() function
PHP explode() function
PHP file_exists() function
PHP function_exists() function
PHP getenv() function
PHP is_readable() function
PHP ksort() function
PHP mkdir() function
PHP ob_start() function
PHP parse_url() function
PHP str_repeat() function
PHP substr() function




Read more articles


General Knowledge



Learn Popular Language