lcg_value()

lcg_value() — Combined linear congruential generator.

Built-in function of PHP 8.5. The manual lists it as available in PHP 4, PHP 5, PHP 7, PHP 8. This page is the reference card: signature, parameters and return value, plus the changelog and the example the manual provides.

The PHP manual marks this function as deprecated (since PHP 8.4): do not use it in new code.

What it does

lcg_value() returns a pseudo random number in the range of (0, 1). The function combines two CGs with periods of 2^31 - 85 and 2^31 - 249. The period of this function is equal to the product of both primes.

Signature

lcg_value(): float

Parameters

This function takes no parameters.

Return value

A pseudo random float value between 0.0 and 1.0, inclusive.

Example

The PHP manual ships no example for lcg_value(); the signature and the parameter table above are the contract.

Changelog

VersionChange
8.4.0This function has been deprecated.

See also

random_int()

All PHP 8.5 built-in functions

Reference card built from the PHP manual page lcg_value() (PHP documentation, CC BY 3.0). The page is generated from the manual, so the wording of the parameter and return value text follows php.net.