\utilRandom

Summary

Methods
Properties
Constants
alnum()
alpha()
numeric()
chinese()
build()
lottery()
uuid()
No public properties found
No constants found
No protected methods found
No protected properties found
N/A
No private methods found
No private properties found
N/A

Methods

alnum()

alnum(int  $len = 6, string  $addChars = '') : string

生成数字和字母含大小写

Parameters

int $len

长度

string $addChars

额外

Returns

string —

alpha()

alpha(int  $len = 6, string  $addChars = '') : string

生成字母含大小写

Parameters

int $len

长度

string $addChars

额外

Returns

string —

numeric()

numeric(int  $len = 4, string  $addChars = '') : string

生成指定长度的随机数字

Parameters

int $len

长度

string $addChars

额外

Returns

string —

chinese()

chinese(int  $len = 4, string  $addChars = '') : string

生成指定长度的随机汉字

Parameters

int $len

长度

string $addChars

额外

Returns

string —

build()

build(string  $type = 'alnum', int  $len = 8, string  $addChars = '') : string

能用的随机数生成

Parameters

string $type

类型 alpha/alnum/numeric/chinese/unique/md5/encrypt/sha1

int $len

长度

string $addChars

额外

Returns

string —

lottery()

lottery(array  $ps, int  $num = 1, bool  $unique = true) : mixed

根据数组元素的概率获得键名

Parameters

array $ps

array('p1'=>20, 'p2'=>30, 'p3'=>50);

int $num

默认为1,即随机出来的数量

bool $unique

默认为true,即当num>1时,随机出的数量是否唯一

Returns

mixed —

当num为1时返回键名,反之返回一维数组

uuid()

uuid() : string

获取全球唯一标识

Returns

string —