PHP gmp_random() functionPHP has a built-in feature called gmp_random() that makes a random number. The range of numeric values will be between zero and the number of bits per limb, multiplied by the limiter. A limb is the internal functionality or mechanism of the GMP function. The number of bits in a limb does not stay the same for each system. It is may different for another system of the GMP function. A limb usually has a default value of 16 or 32 bits, but this is not always the situation. The random number is created on the function's limiter. If the limiter shows a negative value, the number generates negative output. SyntaxThe given syntax shows the GMP function to generate random data. Parameters
Return ValueAs explained above, this function gives a random number as an output. The output data shows between 0(zero), and the number depends on the limb. ExamplesThe given examples show the Random number of the GMP parameter. We can use integer, numerical, binary, and string GMP data. Example1: the given example sets the "random number" of the positive input limiter Output: The given output sets the random values of the input values. Example2: The given example sets the "random number" of the negative input limiter. Output: The given output sets the random values of the input values. Example3: the given example sets the "random number" of the input value. Here, we use a variable with the integer data as an input. Output: The given output sets the random values of the input values. Example4: The given example sets the "random number" of the input value. Here, we use GMP parameter data as input. Here, we use the same input value but get different outputs. Output: The given output sets the random values of the input values. Example5: The given example sets the "random number" of the input value. Here, we use GMP parameter data as input. The input data uses a limiter with an index value and shows the difference between values. Output: The given output sets the random values of the input values. Example6: the given example sets the "random number" of the negative input value. The input data uses a negative limiter with an index value and shows the difference between outputs. Output: The given output sets the random values of the input values. ConclusionThe gmp_random() function shows random values of the given number. It works on positive, negative, integer, and string values and displays output value in minimum code. Next TopicPHP gmp_xor() function |