<?xml version="1.0" encoding="iso-8859-1"?> <!-- $Revision: 1.13 $ --> <!-- splitted from ./en/functions/filesystem.xml, last change in rev 1.2 --> <refentry id="function.copy"> <refnamediv> <refname>copy</refname> <refpurpose>Copies file</refpurpose> </refnamediv> <refsect1> <title>Description</title> <methodsynopsis> <type>bool</type><methodname>copy</methodname> <methodparam><type>string</type><parameter>source</parameter></methodparam> <methodparam><type>string</type><parameter>dest</parameter></methodparam> </methodsynopsis> <para> Makes a copy of the file <parameter>source</parameter> to <parameter>dest</parameter>. &return.success; <example> <title><function>copy</function> example</title> <programlisting role="php"> <![CDATA[ <?php $file = 'example.txt'; $newfile = 'example.txt.bak'; if (!copy($file, $newfile)) { echo "failed to copy $file...\n"; } ?> ]]> </programlisting> </example> </para> <para> If you wish to move a file, use the <function>rename</function> function. </para> <note> <para> As of PHP 4.3.0, both <parameter>source</parameter> and <parameter>dest</parameter> may be URLs if the "fopen wrappers" have been enabled. See <function>fopen</function> for more details. If <parameter>dest</parameter> is a URL, the copy operation may fail if the wrapper does not support overwriting of existing files. </para> </note> <warning> <para> If the destination file already exists, it will be overwritten. </para> </warning> <note> <para> Windows compatibility: If you copy a file with no size, <function>copy</function> will return &false;, but the file will be correctly copied. </para> </note> <para> See also <function>move_uploaded_file</function>, <function>rename</function>, and the section of the manual about <link linkend="features.file-upload">handling file uploads</link>. </para> </refsect1> </refentry> <!-- Keep this comment at the end of the file Local variables: mode: sgml sgml-omittag:t sgml-shorttag:t sgml-minimize-attributes:nil sgml-always-quote-attributes:t sgml-indent-step:1 sgml-indent-data:t indent-tabs-mode:nil sgml-parent-document:nil sgml-default-dtd-file:"../../../../manual.ced" sgml-exposed-tags:nil sgml-local-catalogs:nil sgml-local-ecat-files:nil End: vim600: syn=xml fen fdm=syntax fdl=2 si vim: et tw=78 syn=sgml vi: ts=1 sw=1 -->