PHP | gmp_random_seed() Function Last Updated : 19 Jun, 2018 Comments Improve Suggest changes Like Article Like Report The gmp_random_seed() is an inbuilt function in PHP which sets the RNG seed( Random Number Generation). Syntax: void gmp_random_seed ( mixed $seed ) Parameters: The gmp_random_seed() function accepts a single parameter as mentioned above and explained below: $seed: It is the only parameter required by the gmp_random_seed() function which is to be set for gmp_random(), gmp_random_range() and gmp_random_bits() functions. This parameter can be a GMP resource in PHP 5.5 or earlier, a GMP object in PHP version 5.6 and later, or also allowed to pass a numeric string provided that it is possible to convert that string to a number. Return Value: The gmp_random_seed() function returns NULL on success and returns FALSE on failure. Note: Warning: The function generates an E-Warning and returns False if the seed is not valid. Examples: Below programs illustrate the gmp_random_seed() function in PHP: Program 1: php <?php // PHP code implementing the gmp_random_seed function // setting the seed gmp_random_seed(100); var_dump(gmp_strval(gmp_random(1))); ?> Output: string(19) "7842303329126688544" Program 2: php <?php //php code implementing the gmp_random_seed() function // set the seed to something else gmp_random_seed(gmp_init(-100)); var_dump(gmp_strval(gmp_random_bits(10))); ?> Output: string(3) "800" Program 3: php <?php //PHP code implementing gmp_random_seed() function // set the seed to something invalid var_dump(gmp_random_seed('not a number')); ?> Output: gmp_random_seed(): Unable to convert variable to GMP - string is not an integer -- at line 5 bool(false) Related Articles: PHP | gmp_mod() Function PHP | gmp_random_range() Function Reference: http://php.net/manual/en/function.gmp-random-seed.php Comment More infoAdvertise with us Next Article PHP | gmp_random_seed() Function P priya_1998 Follow Improve Article Tags : Web Technologies PHP PHP-function PHP-gmp Similar Reads PHP | gmp_random() Function The gmp_random() function is an inbuilt function in PHP which generates a random number. The range of random number will be in between zero and the number of bits per limb ( A limb is an internal GMP mechanism. The number of bits in a limb is not static and it can vary from system to system. Usually 2 min read PHP | gmp_random_range() Function The gmp_random_range() is an inbuilt function in PHP which generates a random number.The random number thus generated lies between range min to max. Here GMP refers to (GNU Multiple Precision) which is for large numbers. Syntax: gmp_random_range ( GMP $min, GMP $max ) Parameters: The function accept 2 min read PHP | gmp_random_bits() Function The gmp_random_bits() function is an inbuilt function in PHP which generates a random number. The random number will thus be between the range 0 and (2 * bits) - 1. Here bits must be greater than 0, and the maximum value of bits is restricted by available memory. Here GMP refers (GNU Multiple Precis 2 min read PHP mt_rand( ) Function While working with algorithms we often come across situations when we need to generate random integers. The most common way to generate random numbers is using Mersenne Twister. The Mersenne Twister is a pseudorandom number generator which got its name derived from the fact that its period length is 2 min read PHP | random_int() Function The random_int () is an inbuilt function in PHP. The main function is to generate cryptographically secure pseudo-random integers value. When unbiased results occur in critical condition, then generated cryptographic random integers are used.The different sources of randomness used in this function 2 min read Like