PHP  
downloads | documentation | faq | getting help | mailing lists | reporting bugs | php.net sites | links | my php.net 
search for in the  
<mt_randoctdec>
Last updated: Mon, 16 Jul 2012

mt_srand

(PHP 3 >= 3.0.6, PHP 4, PHP 5)

mt_srand -- 播下一个更好的随机数发生器种子

说明

void mt_srand ( int seed )

seed 来给随机数发生器播种。

<?php
// seed with microseconds
function make_seed() {
   list(
$usec, $sec) = explode(' ', microtime());
   return (float)
$sec + ((float) $usec * 100000);
}
mt_srand(make_seed());
$randval = mt_rand();
?>

注: 自 PHP 4.2.0 起,不再需要用 srand()mt_srand() 函数给随机数生成器播种,现已自动完成。

参见 mt_rand()mt_getrandmax()srand()




<mt_randoctdec>
 Last updated: Mon, 16 Jul 2012
 
Copyright © 2001-2005 The PHP Group
All rights reserved.
This unofficial mirror is operated at: http://manual.phpv.net/
Last updated: Thu Jul 7 19:13:47 2005 CST