gmp_random_seed

(PHP 7)

gmp_random_seedSets the RNG seed

说锟斤拷

gmp_random_seed ( mixed $seed ) : void

锟斤拷锟斤拷

seed

The seed to be set for the gmp_random(), gmp_random_bits(), and gmp_random_range() functions.

锟斤拷锟斤拷锟斤拷一锟斤拷 GMP 锟斤拷锟斤拷 resouce锟斤拷锟斤拷一锟斤拷锟斤拷锟斤拷转锟斤拷为锟斤拷值锟斤拷锟街凤拷锟斤拷锟斤拷

锟斤拷锟斤拷值

Returns NULL on success 锟斤拷锟斤拷锟斤拷失锟斤拷时锟斤拷锟斤拷 FALSE.

锟斤拷锟斤拷锟届常

Issues an E_WARNING and returns FALSE if seed is not valid.

锟斤拷锟斤拷

Example #1 gmp_random_seed() example

<?php
// set the seed
gmp_random_seed(100);

var_dump(gmp_strval(gmp_random(1)));

// set the seed to something else
gmp_random_seed(gmp_init(-100));

var_dump(gmp_strval(gmp_random_bits(10)));

// set the seed to something invalid
var_dump(gmp_random_seed('not a number'));

锟斤拷锟斤拷锟斤拷锟教伙拷锟斤拷锟斤拷锟�

string(20) "15370156633245019617"
string(3) "683"

Warning: gmp_random_seed(): Unable to convert variable to GMP - string is not an integer in %s on line %d
bool(false)

锟轿硷拷