自拍偷在线精品自拍偷,亚洲欧美中文日韩v在线观看不卡

探討PHP函數(shù)mt_srand使用技巧

開發(fā) 后端
PHP函數(shù)mt_srand的語法為void mt_srand ( int seed ),我們可以利用參數(shù)seed來給隨機(jī)數(shù)發(fā)生器播種。希望本文介紹的內(nèi)容能夠幫助大家提高實(shí)際編程能力。

PHP函數(shù)mt_srand是PHP語言中龐大的函數(shù)庫中的一種。它能夠向隨機(jī)數(shù)發(fā)生器播種,利于我們獲取隨機(jī)數(shù)。下面我們講針對(duì)這一函數(shù)的應(yīng)用方法做一個(gè)詳細(xì)的介紹。#t#

PHP函數(shù)mt_srand說明

void mt_srand ( int seed )

用 seed 來給隨機(jī)數(shù)發(fā)生器播種。從 PHP 4.2.0 版開始,seed 參數(shù)變?yōu)榭蛇x項(xiàng),當(dāng)該項(xiàng)為空時(shí),會(huì)被設(shè)為隨時(shí)數(shù)。

例子 1. PHP函數(shù)mt_srand 范例

  1. < ?php  
  2. // seed with microseconds  
  3. function make_seed()  
  4. {  
  5. list($usec, $sec) = explode
    (' ', microtime());  
  6. return (float) $sec + 
    ((float) $usec * 100000);  
  7. }  
  8. mt_srand(make_seed());  
  9. $randval = mt_rand();  
  10. ?>   

 

注: 自 PHP 4.2.0 起,不再需要用 srand() 或PHP函數(shù)mt_srand給隨機(jī)數(shù)發(fā)生器播種,現(xiàn)已自動(dòng)完成。
參見 mt_rand(),mt_getrandmax() 和 srand()。

責(zé)任編輯:曹凱 來源: 新浪博客
相關(guān)推薦

2009-12-10 17:09:42

PHP編碼轉(zhuǎn)換函數(shù)

2009-12-08 11:16:07

PHP動(dòng)態(tài)圖像創(chuàng)建

2009-12-11 13:25:01

PHP頁面跳轉(zhuǎn)

2009-11-30 09:21:39

PHP函數(shù)rmdir(

2009-12-07 16:59:53

PHP匹配顏色函數(shù)

2009-11-30 15:58:13

PHP數(shù)學(xué)函數(shù)

2009-12-01 10:50:45

PHP函數(shù)requir

2009-12-07 10:54:46

PHP uploade

2009-12-07 14:29:08

PHP array_w

2009-11-23 10:31:25

PHP使用JSON

2009-11-27 09:30:58

PHP函數(shù)mb_str

2009-12-03 09:49:59

PHP分頁導(dǎo)航函數(shù)

2009-12-02 15:02:09

PHP simplex

2009-12-15 18:30:56

Ruby使用DBI包裝

2009-12-01 14:26:19

PHP函數(shù)ob_sta

2009-12-11 14:16:13

PHP獲取字段長度

2009-12-08 09:51:10

PHP intval函

2009-12-25 14:18:03

WPF依賴屬性

2009-12-08 14:00:11

PHP函數(shù)microt

2009-12-11 10:59:48

PHP函數(shù)extrac
點(diǎn)贊
收藏

51CTO技術(shù)棧公眾號(hào)