copy one directory to another in php
<pre><code>       &lt;?php
         extract($_REQUEST);
        if(isset($_POST['submit']))
         {
          $get_folder = $_POST['url'];
       $q = mysql_query("insert into test (url) values ('$url')");
        if($q)
        {
        copydir("test",$get_folder);
      function copydir($source,$destination)
       { 
       if(!is_dir($destination))
       {
       $oldumask = umask(0); 
      mkdir($destination, 01777); 
      umask($oldumask);
       }
      $dir_handle = @opendir($source) or die("Unable to open");
     while ($file = readdir($dir_handle)) 
      {
        if($file!="." &amp;&amp; $file!=".." &amp;&amp; !is_dir("$source/$file")) //if it is file
      copy("$source/$file","$destination/$file");
      if($file!="." &amp;&amp; $file!=".." &amp;&amp; is_dir("$source/$file")) //if it is folder
      copydir("$source/$file","$destination/$file");
      }
      closedir($dir_handle);
       }
        }
        }
       ?&gt;
</code></pre>

<p>this is my code ...it shows  Fatal <code>error: Call to undefined function copydir()</code>    in        <code>C:\xampp\htdocs\mywork\creating-folder\1.php</code> on line 14. But when i copy from     <code>copydir("test",$get_folder);</code> to  <code>closedir($dir_handle);</code> in separate file it works   perfectly but instead of $get_folder need to give some static name</p>
