PHP mt_getrandmax() Function

PHPServer Side ProgrammingProgramming

Definition and Usage

The 'mt' prefix in function's name stands for Mersenne Twister. The mt_ getrandmax() function returns largest integer that can be used in PHP. This function uses Mersenne Twister Random Number Generator method. Value returned by this function serves as the upper limit for mt_rand() function to generate random number.

This function always returns an integer.

Syntax

mt_getrandmax ( void ) : int

Parameters

Sr.NoParameter & Description
1This function needs no parameters

Return Values

PHP mt_getrandmax() function use Mersenne Twister Random Number Generator method. and returns largest possible integer that can be used in PHP. On 64 bit Windows, the number is 2147483647

PHP Version

This function is available in PHP versions 4.x, PHP 5.x as well as PHP 7.x.

Example

 Live Demo

Following example returns largest possible integer −

<?php
   echo "Largest Integer = " . mt_getrandmax() . "\n";
?>

Output

This returns largest integer−

Largest Integer = 2147483647
raja
Published on 30-Jun-2020 10:36:54
Advertisements