echo ""; echo ""; echo ""; echo ""; if(!is_admin){echo "";} » PHP中的随机数生成 仲子说

2008-11-25

PHP中的随机数生成

Posted in PHP at 12:33 Author:仲远

标签:

??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????

?PHP??????????????????????

  1. //???:?????
  2. $seedarray =microtime();
  3. $seedstr =split(" ",$seedarray,5);
  4. $seed =$seedstr[0]*1000000;
  5.  
  6. //???:?????????????
  7. srand($seed);
  8.  
  9. //???:???????????
  10. $random =rand(0,1000);

????????????????????????0?1000????0?1000???????????0??????????????????????

??????????????????

  1. srand((double)microtime()*1000000);
  2. $random =rand(0,1000);

???microtime()????????????????????????????????????????(double)microtime()???????????????microtime()?????????????????????1000000????????????????0?1000?????????

??????????PHP?????????

本文可以自由转载,转载时请保留全文并注明出处:
转载自仲子说 [ http://www.wangzhongyuan.com/ ]
原文链接:

1 Comment »

  1. Spirit said,

    2008年November25日 at 14:33

    还是Java省事儿~

Leave a Comment

*
To prove you're a person (not a spam script), type the security text shown in the picture. Click here to regenerate some new text.
Click to hear an audio file of the anti-spam word