PHP copy() Function

❮ PHP Filesystem Reference

Example

Copy "source.txt" to "target.txt":

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


Definition and Usage

The copy() function copies a file.

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

Syntax

copy(from_file, to_file, context)

Parameter Values

Parameter Description
from_file Required. Specifies the path to the file to copy from
to_file Required. Specifies the path to the file to copy to
context Optional. Specifies a context resource created with stream_context_create()


Technical Details

Return Value: TRUE on success, FALSE on failure
PHP Version: 4.0+
PHP Changelog: PHP 5.3 - Added context parameter

❮ PHP Filesystem Reference
Copyright 1999-2023 by Refsnes Data. All Rights Reserved.