In PHP how to calculate a random number?

Question:

How to calculate a random integer between 1 and 2000 using PHP, to make a draw?

function random() {
  // codigo
}

Answer:

Use a função mt_rand

$numero = mt_rand(1, 2000);
echo $numero;

See more about this function at this link.

Scroll to Top