array ( 0 => 'index.php', 1 => 'PHP Manual', ), 'head' => array ( 0 => 'UTF-8', 1 => 'fr', ), 'this' => array ( 0 => 'function.gmp-random-seed.php', 1 => 'gmp_random_seed', ), 'up' => array ( 0 => 'ref.gmp.php', 1 => 'Fonctions GMP', ), 'prev' => array ( 0 => 'function.gmp-random-range.php', 1 => 'gmp_random_range', ), 'next' => array ( 0 => 'function.gmp-random.php', 1 => 'gmp_random', ), 'alternatives' => array ( ), 'source' => array ( 'lang' => 'fr', 'path' => 'reference/gmp/functions/gmp-random-seed.xml', ), ); $setup["toc"] = $TOC; $setup["toc_deprecated"] = $TOC_DEPRECATED; $setup["parents"] = $PARENTS; manual_setup($setup); ?>
(PHP 7, PHP 8)
gmp_random_seed — Définit la graine RNG (Générateur de Nombres Aléatoire)
seed
La graine à définir pour les fonctions gmp_random(), gmp_random_bits(), et gmp_random_range().
Un objet GMP, un entier, ou une chaîne de caractères numérique.
Aucune valeur n'est retournée.
Lève une exception ValueError si le
paramètre seed
est invalide.
Version | Description |
---|---|
8.0.0 |
Si le paramètre seed est invalide, gmd_random_seed()
lève une exception ValueError dorénavant.
Précédemment une alerte E_WARNING était émise.
|
Exemple #1 Exemple avec gmp_random_seed()
<?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'));
L'exemple ci-dessus va afficher :
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)