Horje
PHP mt_getrandmax() Function

The mt_getrandmax() is an inbuilt function in PHP that is used to return the largest possible value of random numbers.

Syntax

mt_getrandmax(): int

Parameter

This function does not accept any parameter.

Return Value

The mt_getrandmax() function returns the integer representing the maximum value that can be generated by the mt_rand() Function.

Program 1: The following program demonstrates mt_getrandmax() Function.

PHP

<?php
    
// Get the maximum random number that
// can be generated using mt_rand()
$maxRandomValue = mt_getrandmax();
echo "Maximum random number: " . $maxRandomValue;
?>

Output

Maximum random number: 2147483647

Program 2: The following program demonstrates mt_getrandmax() Function.

PHP

<?php
$randomNumber = mt_rand(0, mt_getrandmax());
echo "Random number: " . $randomNumber . PHP_EOL;
?>

Output

Random number: 2084185664

Reference: https://www.php.net/manual/en/function.mt-getrandmax.php




Reffered: https://www.geeksforgeeks.org


PHP

Related
PHP readline_add_history() Function PHP readline_add_history() Function
PHP mb_ereg_search_pos() Function PHP mb_ereg_search_pos() Function
PHP mb_stristr() Function PHP mb_stristr() Function
UPSSSC PET Syllabus 2024: Subject-Wise, Exam Pattern, PDF Download UPSSSC PET Syllabus 2024: Subject-Wise, Exam Pattern, PDF Download
PHP gmp_lcm() Function PHP gmp_lcm() Function

Type:
Geek
Category:
Coding
Sub Category:
Tutorial
Uploaded by:
Admin
Views:
10