Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and medical aesthetics - What is a php random floating-point number? Like a random floating point number from 0. 1 to 3.0?
What is a php random floating-point number? Like a random floating point number from 0. 1 to 3.0?
You can use rand () function to generate a random number in PHP, but you can't generate floating-point numbers directly. You can generate floating-point numbers by one step.

We can make it a number of 1-30 and put it in 10.

& lt? Server-side programming language (abbreviation of professional hypertext preprocessor)

$num? =? Rand (1, 30)/10;

Echo? $num

& gt at this time, the value of num is a random floating point number in 0. 1-3.0.

Usage of rand () function

int? Rand? (? int? $min? ,? int? $max? )

These parameters are:

department

Lowest value returned (default: 0)

maximum

Maximum value returned (default: getrandmax ())

For other ways to use the rand () function, please visit the official document: PHP document.