Welcome to bytea
当前位置: Home 学习资料 网站制作 php生成随机数-srand 今天是...date...

登录bbs

用户名
密码

bytea统计

Members : 43193
Content : 333
Web Links : 69
php生成随机数-srand PDF Print E-mail
Sunday, 20 March 2005 08:22

srand

配置随机数种子。

语法: void srand(int seed);

返回值: 无

函数种类: 数学运算

内容说明

本函数传入参数 seed 后,配置随机数的种子。值得注意的是参数 seed 值最好也是随机出现的数字,例如利用加入时间做为变量的来源就是不错的方法,或者开发其它的硬体周边界面可取得更好的随机数。

使用范例

本例加入时间的因素,以执行时的百万分之一秒当随机数种子

<?php
srand((double)microtime()*1000000);
$randval = rand();
echo $randval;
?>

Comments (0)Add Comment

Write comment
quote
bold
italicize
underline
strike
url
image
quote
quote
smile
wink
laugh
grin
angry
sad
shocked
cool
tongue
kiss
cry
smaller | bigger

security code
Write the displayed characters


busy
 

支持本站:



Connect with me via QQ:38074 or e-mail:

©2006 bytea.net All Copyrights Reserved.

本站备案编号:保密^_^

RSS:  

开启背景音乐