title: 127.0.0.1 site cant be reached. Connection reset
body: <p>I am trying to delete folders and recreate new and populate with new files</p>
  <p>My PHP Code is as below</p>
  <pre><code>&lt;?php 
  set_time_limit(0);
  
  function delete_files($dir) {
    if (is_dir($dir)) {
      $objects = scandir($dir);
      foreach ($objects as $object) {
        if ($object != &quot;.&quot; &amp;&amp; $object != &quot;..&quot;) {
          if (filetype($dir.&quot;/&quot;.$object) == &quot;dir&quot;) 
             delete_files($dir.&quot;/&quot;.$object); 
          else{if(is_file($dir.&quot;/&quot;.$object)){ unlink   ($dir.&quot;/&quot;.$object);}}
        }
      }
      reset($objects);
      rmdir($dir);
    }
   }
  
  
  function recurse_copy($dir,array $scmum){
  //  var_dump($scmum);
          foreach($scmum as $scf){
              if(!is_dir($scf) &amp;&amp; $scf!='.htaccess' &amp;&amp; $scf!='.' &amp;&amp; $scf!='..'){
                  if(copy(&quot;$basedir/$scf&quot;,&quot;$dir/$scf&quot;)){
                      if(is_file(&quot;$dir/.htaccess&quot;)){
                              unlink(&quot;$dir/.htaccess&quot;);
                          }
                          echo &quot;$dir/$scf Copied&lt;br&gt;&quot;;
                  }else{
                      $e=error_get_last();echo &quot;Error 0 :&quot;.$e['message'].&quot;&lt;br&gt;&quot;;
                  }
              }
                  else{
                      recurse_copy($scf,$scmum);
                  }
              }
      }
  
  $basedir=&quot;subdomainfiles&quot;;
  $scmum=scandir($basedir); 
  include('connnew.php');
  $getcities=$maindb-&gt;query(&quot;SELECT Location from clientdata GROUP BY Location ORDER BY Location ASC&quot;) or die($maindb-&gt;error);
  while($infocit=$getcities-&gt;fetch_assoc()){
      $cityU=UCfirst(strtolower(str_replace(array(&quot; &quot;,&quot;,&quot;),&quot;-&quot;,$infocit['Location'])));
      $cityL=strtolower(str_replace(array(&quot; &quot;,&quot;,&quot;),&quot;-&quot;,$infocit['Location']));
      $title=$cityU;
      if(is_dir($cityU)){delete_files($cityU);}
      if(is_dir($cityL)){delete_files($cityL);}
      mkdir($cityL,0777,true);
  //  var_dump($scmum);
      recurse_copy($cityL,$scmum);    
  }
  </code></pre>
  <p>However, I get the above captioned error. The screen shot is below</p>
  <p><a href="https://i.stack.imgur.com/J5tSL.png" rel="nofollow noreferrer">Error Page</a></p>
  <blockquote>
  <p>&quot;This site can’t be reached  The connection was reset. Try:</p>
  <p>Checking the connection Checking the proxy and the firewall Running
  Windows Network Diagnostics ERR_CONNECTION_RESET&quot;</p>
  </blockquote>
  <p>Could this be because of the looping of the functions ?</p>