Javatpoint Logo
Javatpoint Logo

PHP gmp_random_seed() function

The PHP GMP gmp_random_seed() function is used to set a random number generation (RNG) seed using the given GMP number.

Syntax

The syntax shows the GMP function to get a random number generation seed.

Parameters

  • The above GMP syntax shows that this function uses a single GMP parameter or numerical data. The parameters are written as a $seed_parameter.
  • PHP version 5.6 and afterword versions use the gmp_random_seed() function. The string data is converted into the numeric or integer value.
  • It is the single input parameter that the gmp random seed() function needs to be set random number for the "gmp_random()", the "gmp random range()", and the "gmp random bits()" GMP functions.

Return Value

  • If the gmp_random_seed() function works, it returns NULL value.
  • If the gmp_random_seed() function does not works, it returns FALSE value.

Examples

The given examples show the RNG seed of the GMP parameter. We can use integer, numerical, binary, and string GMP data.

Example1: the given example sets the "random number generate seed" of the positive input value. Here, we use the numerical value and text data in the example.

Output:

The following output sets the RNG values of the given values.

PHP gmp_random_seed() function

Example2: the given example sets the "random number generate seed" of the input value. here we use the RNG value with the GMP the "gmp_random()", the "gmp_random_range()", and the "gmp_random_bits()" functions.

Output:

The following output sets the RNG values of the given values.

PHP gmp_random_seed() function

Example3: the given an example sets the "random number generate seed" of the input value. Here, we use the numerical value and text data as input parameters. The GMP function is used for initializing data and working in the gmp_random_seed() function.

Output:

The following output sets the RNG values of the given values.

PHP gmp_random_seed() function

Example4: the given an example sets the "random number generate seed" of the input value. We can see the difference between before and after using the function.

Output:

The following output sets the RNG values of the given values.

PHP gmp_random_seed() function

Example5: the given an example sets the "random number generate seed" of the text value. Here, we uses the "gmp_random()" and the "gmp_random_bits()" function.

Output:

The following output sets the RNG values of the given values.

PHP gmp_random_seed() function

Example6: the given an example sets the "random number generate seed" of the negative input value.

Output:

The following output sets the RNG values of the given values.

PHP gmp_random_seed() function

Conclusion

The random_seed() function is used to set values for other GMP functions. This function is used for mathematical operations in a single line.







Youtube For Videos Join Our Youtube Channel: Join Now

Feedback


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA