I have a script that calls the rand function:
<?php
echo rand(0, 9);
?>
If I run this script multiple times, will I get different numbers out, or will it always be the same? In other words, does PHP seed rand automatically?
I have a script that calls the rand function:
<?php
echo rand(0, 9);
?>
If I run this script multiple times, will I get different numbers out, or will it always be the same? In other words, does PHP seed rand automatically?
YES! you can get the exact number between 0-9 twice in a row. Whatever you're asking, you'll find it in PHP's rand() manual.
Before version 4.2.0, it will output the same value every time; you're supposed to call srand() to seed it. Starting with 4.2.0, the random number generator is seeded automatically (see the rand() changelog), so you'll get different outputs every time you run the script