<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<refentry xmlns="http://docbook.org/ns/docbook" xml:id="function.copy">
 <refnamediv>
  <refname>copy</refname>
  <refpurpose>Copies file</refpurpose>
 </refnamediv>
 
 <refsect1 role="description">
  &reftitle.description;
  <methodsynopsis>
   <type>bool</type><methodname>copy</methodname>
   <methodparam><type>string</type><parameter>source</parameter></methodparam>
   <methodparam><type>string</type><parameter>dest</parameter></methodparam>
   <methodparam choice="opt"><type>resource</type><parameter>context</parameter></methodparam>
  </methodsynopsis>
  <para>
   Makes a copy of the file <parameter>source</parameter> to
   <parameter>dest</parameter>.
  </para>
  <para>
   If you wish to move a file, use the <function>rename</function> function.
  </para>
 </refsect1>

 <refsect1 role="parameters">
  &reftitle.parameters;
  <para>
   <variablelist>
    <varlistentry>
     <term><parameter>source</parameter></term>
     <listitem>
      <para>
       Path to the source file.
      </para>
     </listitem>
    </varlistentry>
    <varlistentry>
     <term><parameter>dest</parameter></term>
     <listitem>
      <para>
       The destination path. If <parameter>dest</parameter> is a URL, the
       copy operation may fail if the wrapper does not support overwriting of
       existing files.
      </para>
      <warning>
       <para>
        If the destination file already exists, it will be overwritten.
       </para>
      </warning>
     </listitem>
    </varlistentry>
    <varlistentry>
     <term><parameter>context</parameter></term>
     <listitem>
      <para>
       A valid context resource created with 
       <function>stream_context_create</function>.
      </para>
     </listitem>
    </varlistentry>
   </variablelist>
  </para>
 </refsect1>

 <refsect1 role="returnvalues">
  &reftitle.returnvalues;
  <para>
   &return.success;
  </para>
 </refsect1>

 <refsect1 role="changelog">
  &reftitle.changelog;
  <para>
   <informaltable>
    <tgroup cols="2">
     <thead>
      <row>
       <entry>&Version;</entry>
       <entry>&Description;</entry>
      </row>
     </thead>
     <tbody>
      <row>
       <entry>5.3.0</entry>
       <entry>
        Added context support.
       </entry>
      </row>
      <row>
       <entry>4.3.0</entry>
       <entry>
        Both <parameter>source</parameter> and <parameter>dest</parameter>
        may now be URLs if the "fopen wrappers" have been enabled.
        See <function>fopen</function> for more details.
       </entry>
      </row>
     </tbody>
    </tgroup>
   </informaltable>
  </para>
 </refsect1>

 <refsect1 role="examples">
  &reftitle.examples;
  <para>
   <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>
 </refsect1>

 <refsect1 role="seealso">
  &reftitle.seealso;
  <para>
   <simplelist>
    <member><function>move_uploaded_file</function></member>
    <member><function>rename</function></member>
    <member>The section of the manual about <link 
     linkend="features.file-upload">handling file uploads</link></member>
   </simplelist>
  </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:"~/.phpdoc/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
-->