mt_rand(1000000000, 9999999999);
Warning: mt_rand() expects parameter 2 to be integer, float given in E:\Projects\school\users\temp.php on line 6
PHP 7.0.2 in XAMPP. This code was running fine in last XAMPP installation which had 5.x. So the update broke it. Can't find anything on google.
Large ints are stored as floats if they overflow the maximum int value on the operating system of your server. On 32-bit systems, they overflow above 2147483647. On 64-bit systems, they overflow above 9223372036854775807.
You can use var_dump(PHP_INT_MAX) if you want to see the max int on your server.
If you want to ensure that it doesn't overflow regardless of the system it is running on, you can use mt_getrandmax() as your second argument
mt_rand(1000000000, mt_getrandmax())
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With