Curriculum
Course: PHP Basic
Login

Curriculum

PHP Basic

PHP Install

0/1

PHP Casting

0/1

PHP Constants

0/1

PHP Magic Constants

0/1

PHP Operators

0/1

PHP Reference

0/276
Text lesson

copy()

Example

Duplicate “source.txt” to “target.txt”.

<?php
echo copy(“source.txt”,“target.txt”);
?>

Definition and Usage

The copy() function duplicates a file.

 

Note: If the destination file already exists, it will be overwritten.

Syntax

copy(from_fileto_filecontext)

Parameter Values

 

Parameter

Description

from_file

Mandatory. Specifies the path of the file to be copied.

to_file

Mandatory. Specifies the path where the file should be copied to.

context

Optional. Specifies a context resource created using stream_context_create().

Technical Details

Return Value:

Returns TRUE on success and FALSE on failure.

PHP Version:

4.0+

PHP Changelog:

PHP 5.3 introduced the context parameter.