0

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.

I have tried for() loop and sleep()

//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->write('fileeeeeeee', 'FDSABNIFGA', 0);

echo $time = microtime(true) - $start;


//secondFile.php

$rw = new RW();

$start = microtime(true);

    $rw->write('fileeeeeeee', 'HEHEEH', 0);

echo $time = microtime(true) - $start;

I need to run firstFile.php and secondFile.php at exactly the same time in the browser.

1 Answers1

0

If you want to deliberately crash a script you could just setup an infinite loop.

for($i = 1; $i != 0; $i++) {
    echo $i . '<br />';
}
Mark
  • 1,852
  • 3
  • 18
  • 31