|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2004-09-11 14:30 UTC] tony2001@php.net
[2004-09-19 01:00 UTC] php-bugs at lists dot php dot net
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Oct 26 08:00:02 2025 UTC |
Description: ------------ I use rand(min, max) in a php script in a web page that is working pretty well. But I also use it when this page open another (small) window with another page that call the function rand() too. This is working pretty well except when I reload the parent window and open again the small one, then the rand() function will return exactly the latest number !!! Idem with srand() mt_rand() For exemple on my parent window I click on my button "new" this will open the small window and generate 5 I click again on "new" this will close and then reopen the small window and generate 8 etc . . . and then if I click on new and it'll open the small window and generate for exemple 6 after that I reload the parent window and click again on "new" I will get a 6 again After that if I click again on "new" it 'll be another one but if I reload the parent again, I'll definitely get a 6 again, and so on . . . Reproduce code: --------------- $nb = mysql_num_rows($resultMorceau); if ($nob > 0) { srand(); $hasard = mt_rand(0 , $nb-1); echo hasard; } Expected result: ---------------- I'd like to get a random number even if I reload my parent window frame !