Overview
KB
Technical FAQ
PHP Manual
CSS2 Manual
HTML Manual
JS Guide
JS Reference
PhpDock Manual
Nu-Coder Manual
PhpExpress Manual
PHP Joomla
Development
Learn PHP
 
<Random\Randomizer::getFloatRandom\Randomizer::nextFloat>
^Random\RandomizerLast updated: Mon, 26 Oct 2026

Random\Randomizer::getInt

(PHP 8 >= 8.2.0)

Random\Randomizer::getInt — Get a uniformly selected integer

Description

public function Random\Randomizer::getInt(int $min, int $max): int

Parameters

min

The lowest value to be returned.

max

The highest value to be returned.

Return Values

A uniformly selected integer from the closed interval [min, max]. Both min and max are possible return values.

Errors/Exceptions

Examples

Example #1 Random\Randomizer::getInt() example

<?php
$r = new \Random\Randomizer();

// Random integer in range:
echo $r->getInt(1, 100), "\n";
?>

The above example will output something similar to:

42

See Also


<Random\Randomizer::getFloatRandom\Randomizer::nextFloat>
^Random\RandomizerLast updated: Mon, 26 Oct 2026