Jesus · Bible · HTML · CSS · JS · PHP · SVG · Applications

gmp_random_seed

Description

The gmp_random_seed of GMP for PHP sets the RNG seed.

Syntax

gmp_random_seed(
    GMP|int|string $seed
): void

Parameters

seed

The seed to be set for gmp_random_bits() and gmp_random_range().

A GMP object, an int or a numeric string.

Return

No value is returned.

Examples

1 · seed · GMP

<?

$bits = 3;

$gmp_random_bits = gmp_random_bits($bits);

var_dump($gmp_random_bits);

$min = -10;
$max = 10;

$gmp_random_range = gmp_random_range($min, $max);

var_dump($gmp_random_range);

$seed = 100;

$seed = gmp_init($seed);

gmp_random_seed($seed);

$gmp_random_bits = gmp_random_bits($bits);

var_dump($gmp_random_bits);

$gmp_random_range = gmp_random_range($min, $max);

var_dump($gmp_random_range);

?>
object(GMP)#1 (1) {
  ["num"]=>
  string(1) "0"
}
object(GMP)#2 (1) {
  ["num"]=>
  string(1) "2"
}
object(GMP)#4 (1) {
  ["num"]=>
  string(1) "0"
}
object(GMP)#1 (1) {
  ["num"]=>
  string(1) "9"
}

2 · seed · int

<?

$bits = 3;

$gmp_random_bits = gmp_random_bits($bits);

var_dump($gmp_random_bits);

$min = -10;
$max = 10;

$gmp_random_range = gmp_random_range($min, $max);

var_dump($gmp_random_range);

$seed = 100;

gmp_random_seed($seed);

$gmp_random_bits = gmp_random_bits($bits);

var_dump($gmp_random_bits);

$gmp_random_range = gmp_random_range($min, $max);

var_dump($gmp_random_range);

?>
object(GMP)#1 (1) {
  ["num"]=>
  string(1) "4"
}
object(GMP)#2 (1) {
  ["num"]=>
  string(2) "-6"
}
object(GMP)#3 (1) {
  ["num"]=>
  string(1) "0"
}
object(GMP)#1 (1) {
  ["num"]=>
  string(1) "9"
}

3 · seed · string

<?

$bits = 3;

$gmp_random_bits = gmp_random_bits($bits);

var_dump($gmp_random_bits);

$min = -10;
$max = 10;

$gmp_random_range = gmp_random_range($min, $max);

var_dump($gmp_random_range);

$seed = "100";

gmp_random_seed($seed);

$gmp_random_bits = gmp_random_bits($bits);

var_dump($gmp_random_bits);

$gmp_random_range = gmp_random_range($min, $max);

var_dump($gmp_random_range);

?>
object(GMP)#1 (1) {
  ["num"]=>
  string(1) "3"
}
object(GMP)#2 (1) {
  ["num"]=>
  string(2) "10"
}
object(GMP)#3 (1) {
  ["num"]=>
  string(1) "0"
}
object(GMP)#1 (1) {
  ["num"]=>
  string(1) "9"
}
HomeMenu