- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
PHP lcg_value() Function
Definition and Usage
The lcg_value() function generates a random number between 0 and 1.
LCG stands for linear congruential generator. This generator generates a sequence of pseudo-randomized numbers calculated with a discontinuous piecewise linear equation. This is one of the oldest pseudorandom number generator algorithms
Syntax
lcg_value ( void ) : float
Parameters
Return Values
PHP lcg_value() function returns a pseudo random float value between 0.0 and 1.0, inclusive.
PHP Version
This function is available in PHP versions 4.x, PHP 5.x as well as PHP 7.x.
Example
Following is the example use of lcg_value() function −
<?php echo "lcg_value() = " . lcg_value() . "
"; echo "lcg_value() = " . lcg_value(); ?>
Output
This may produce following result −
lcg_value() = 0.45920201711279 lcg_value() = 0.18118693614628
Advertisements