Php copy function tutorial

Source: Internet
Author: User

Copy
(PHP 4 and PHP 5)

Copy-Copy an object

Description
Boolean copy (string $ Source, string $ dest [, resource $ background])
Make the file a copy source dest.

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

Parameters

Source
Path source file.

Dest
Destination path. If dest is a Web site, the copy operation may fail. If the package does not support overwriting existing files.

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

Background
Create stream_context_create () within the effective range of the resource ().


Return value
Returns TRUE or FALSE.

Modify

Version description
5.3.0 time support.
4.3.0 source and dest may now be URLs if "open package" is enabled. For more information about the fopen () function, see.


Instance

Example of #1 copy ()

<? Php
$ File = 'example.txt ';
$ Newfile = 'example.txt. bak ';

If (! Copy ($ file, $ newfile )){
Echo "failed to copy $ file... n ";
}
?>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.