Home >Backend Development >PHP Tutorial >How to use php copy function

How to use php copy function

藏色散人
藏色散人Original
2019-02-21 13:27:384311browse

The copy() function is a built-in function in PHP, used to make a copy of the specified file, that is, copy the file. It copies a copy of the source file to the target file. If the target file already exists, it will be Override, the [copy()] function returns true when successful and false when failed.

How to use php copy function

php copy() function usage:

Function:Copy files.

Syntax:

copy(source,destination)

Parameters:

source: Required. Specifies the files to be copied.

destination: Required. Specifies the destination for copied files.

Return value: Returns true when successful and false when failed.

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

php copy() function example

<?php
$file = "index.php";
$res = copy($file,"test.txt");
if($res)
{
    echo "文件复制成功";
}else{
    echo "文件复制失败";
}
?>

This article is about how to use the copy function. I hope it will be helpful to friends in need!

The above is the detailed content of How to use php copy function. For more information, please follow other related articles on the PHP Chinese website!

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