Home  >  Article  >  Backend Development  >  php copy function tutorial_PHP tutorial

php copy function tutorial_PHP tutorial

WBOY
WBOYOriginal
2016-07-20 11:00:44954browse

Let’s take a look at this php copy function tutorial. ​

copy
(PHP 4, PHP 5)

Copy - Copy file

Description
boolean copy(string$source, string$dest[, resource$background])
Makes a copy of the file dest.

If you want to move the file, please use the rename() function.

Parameters

Source
The path to the source file.

dest
Destination path. If dest is a URL, the copy operation may fail if the wrapper does not support overwriting existing files.

Warning
If the target file already exists, it will be overwritten.

Background
Establish stream_context_create() within the valid scope of the resource.


Return value
Returns TRUE or FALSE on success or failure.

Modify

Release Notes
5.3.0 timing support.
4.3.0 source and dest may now be urled if "unpack" is enabled. See the fopen() function for more details.


Example

Example of #1copy()

$file = 'example.txt';
$newfile = 'example.txt.bak';

if (!copy($file, $newfile)) {
echo "failed to copy $file...n";
}
?>


www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/445489.htmlTechArticleLet’s take a look at this php copy function tutorial. copy (PHP 4, PHP 5) copy - copy file description boolean copy(String$source, String$dest[, Resource$background]) Make...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn