Home >>PHP Math Functions >PHP lcg_value() Function

PHP lcg_value() Function

PHP lcg_value() Function

PHP lcg_value() function is used to generate a pseudo-random number between the range of 0 and 1. It does not take any input parameters. It returns a pseudo random value of float type as output that be in the range between 0 and 1.

Syntax:

  lcg_value();

Here is an example of lcg_value() Function in PHP:

<html>
<body>

<?php

echo lcg_value();
echo "<br>";
echo lcg_value();
echo "<br>";
echo lcg_value();
echo "<br>";
echo lcg_value();
echo "<br>";
echo lcg_value();
echo "<br>";
echo lcg_value();
echo "<br>";
echo lcg_value();

?>

</body>
</html>
Output:
0.54741361133829
0.69731083596847
0.79056220560975
0.35031678132014
0.4068766337892
0.20179416044222
0.95804115714354

No Sidebar ads