<?php
// FIRST DESCRIPTION
int mt_rand ()
?>
<?php
// SECOND DESCRIPTION
int mt_rand ( int $min, int $max );
where,
$min = the minimum integer value
of the numeric interval
$max = the maximun integer value
of the numeric interval
mt_getrandmax = 2147483647
?>
<?php
// Run this code several times
$mtrd01 = mt_rand();
echo 'The generated random number
for this system in this moment, is: '
. $mtrd01 . '.<br><br>';
?>
<?php
// Run this code several times
$min02 = 10;
$max02 = 20;
$mtrd02 = mt_rand($min02, $max02);
echo 'The random number generated
for this system, within the numerical range:<br>['
. $min02 . ', ' . $max02 . '], at this point is '
. $mtrd02 . '.<br><br>'
?>
<?php
// Run this code several times
$min03 = 0;
$max03 = mt_getrandmax();
$mtrd03 = mt_rand($min03, $max03);
echo 'The random number generated
for this system, within the numerical range:<br>['
. $min03 . ', ' . $max03 . '], at this point is '
. $mtrd03 . '.<br><br>';
?>
<?php
// Run this code several times
$min04 = PHP_INT_MIN;
// -9223372036854775808 -> (64bit)
$max04 = PHP_INT_MAX;
// 9223372036854775807 -> (64bit)
$mtrd04 = mt_rand($min04, $max04);
echo 'The random number generated
for this system, within the numerical range:<br>['
. $min04 . ', ' . $max04 . '], at this point is '
. $mtrd04 . '.<br><br>';
?>
<?php
// This code generates a
// Warning in PHP 7.4.XX
// and a
// Fatal error in PHP 8.0.XX and PHP 8.1.XX.
$min05 = (PHP_INT_MIN - 1);
// -9223372036854775809
$max05 = (PHP_INT_MAX + 1);
// 9223372036854775808
// Causes of Warning and Fatal error
$rd05 = mt_rand($min05, $max05);
$min05a = (PHP_INT_MIN);
// -9223372036854775808 -> (64bit)
$max05a = (PHP_INT_MAX);
// 9223372036854775807 -> (64bit)
$rd05a = mt_rand($min05a, $max05a);
echo 'The random number generated
for this system, within the numerical range:<br>['
. $min05a . ', ' . $max05a . '], at this point is '
. $rd05a . '.<br><br>';
?>