mercredi 10 février 2021

php simple rand() look up taking long / crashing browser?

I'm running this code:

$n1 = rand(1,20);
$n2 = rand(1,20);
echo '<p>Looking for ' . $z1;
echo '<p>looking....<br><br>';
for ($i = 1; $n1 != $n2; $i ++) {
  $n2 = rand(1,10);
}

echo '<p>I tried ' . $i . ' times.</p>';

First loads of the page are usually super fast. Then suddenly:

Fatal error: Maximum execution time of 120 seconds exceeded

It's either working super fast or crashing. Can someone help me understand why this is?

Thank You




Aucun commentaire:

Enregistrer un commentaire