title: How to run two php scripts at the same time in browser and fwrite() in the same file
body: <p>I have to crash the script. I have a class with a method that opens and writes in the file. I have 2 more files that are the same for calling this method.</p>
  
  <p>I have tried for() loop and sleep()</p>
  
  <pre class="lang-php prettyprint-override"><code>//Method
      public function write($filename, $text, $sleep)
      {
          $filename .= '.txt';
          $fh = fopen($filename, 'w');
          flock($fh, LOCK_EX);
          $write = fwrite($fh, $text);
          if ($sleep != 0) {
              sleep($sleep);
          }
          fclose($fh);
          return $write;
      }
  
  
  //firstFile.php
  
  $rw = new RW();
  
  $start = microtime(true);
  
  $rw-&gt;write('fileeeeeeee', 'FDSABNIFGA', 0);
  
  echo $time = microtime(true) - $start;
  
  
  //secondFile.php
  
  $rw = new RW();
  
  $start = microtime(true);
  
      $rw-&gt;write('fileeeeeeee', 'HEHEEH', 0);
  
  echo $time = microtime(true) - $start;
  </code></pre>
  
  <p>I need to run firstFile.php and secondFile.php at exactly the same time in the browser.</p>