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.
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!