title: PHP: Copy entire contents of a directory
body: <p><strong>Sorry for new post!</strong> I'm not yet trusted to comment on others posts.</p>
  
  <p>I'm having trouble copying folders and this is where I started:
  <a href="https://stackoverflow.com/a/2050909/5649888">Copy entire contents of a directory</a></p>
  
  <p><strong>Function</strong></p>
  
  <pre><code>function recurse_copy($src,$dst) { 
      $dir = opendir($src); 
      @mkdir($dst); 
      while(false !== ( $file = readdir($dir)) ) { 
          if (( $file != '.' ) &amp;&amp; ( $file != '..' )) { 
              if ( is_dir($src . '/' . $file) ) { 
                  recurse_copy($src . '/' . $file,$dst . '/' . $file); 
              } 
              else { 
                  copy($src . '/' . $file,$dst . '/' . $file); 
              } 
          } 
      } 
      closedir($dir); 
  }
  </code></pre>
  
  <p><strong>My input</strong></p>
  
  <pre><code>$src = "http://$_SERVER[HTTP_HOST]/_template/function/";
  $dst = "http://$_SERVER[HTTP_HOST]/city/department/function/";
  recurse_copy($src, $dst);
  </code></pre>
  
  <p>I've also tried this</p>
  
  <pre><code>$src = "$_SERVER[DOCUMENT_ROOT]/_template/function/"; // And so on...
  </code></pre>
  
  <p>The function is executed but nothing is being copied.</p>
  
  <p>Any ideas on what might be wrong?</p>
  
  <p><strong>SOLVED</strong></p>
  
  <p><a href="https://stackoverflow.com/a/35310905/5649888">Working solution</a></p>
  
  <p>Along with</p>
  
  <pre><code>$src = "$_SERVER[DOCUMENT_ROOT]/_template/function/";
  $dst = "$_SERVER[DOCUMENT_ROOT]/city/department/function/";
  recurse_copy($src, $dst);
  </code></pre>