Home  >  Article  >  php教程  >  php copy 函数教程

php copy 函数教程

WBOY
WBOYOriginal
2016-06-13 11:17:001048browse

下面来看看这款php copy 函数教程吧。  

copy
( PHP 4中, PHP 5中)

复制-复制文件

描述
布尔copy(字符串$来源,字符串$ dest [ ,资源$背景] )
使文件的一个copy源dest 。

如果你想移动的文件,请使用重新命名( )函数。

参数

来源
路径的源文件。

dest
目的地路径。如果dest是一个网址,复制操作可能会失败,如果包装不支持覆盖现有的文件。

警告
如果目标文件已经存在,它会被覆盖。

背景
资源的有效范围内建立stream_context_create ( ) 。


返回值
返回TRUE或FALSE的成功失败。

修改

版本说明
5.3.0时间方面的支持。
4.3.0来源和dest现在可能网址如果“打开包装”已启用。见fopen ( )函数的更多细节。


实例

例如# 1copy( )的例子

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

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


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