Class Rand

Summary

Fully Qualified Name: Laminas\Math\Rand

Description

Pseudorandom number generator (PRNG)

Methods

Name Description Defined By
getBoolean() Generate random boolean Rand
getBytes() Generate random bytes using different approaches If PHP 7 is running we use the random_bytes() function Rand
getFloat() Generate random float [0. Rand
getInteger() Generate a random integer between $min and $max Rand
getString() Generate a random string of specified length. Rand

Method Details

getBoolean()

Generate random boolean

Returns: bool

getBytes()

Generate random bytes using different approaches If PHP 7 is running we use the random_bytes() function

Parameter Name Type Description
$length int

Returns: string

getFloat()

Generate random float [0.

.1) This function generates floats with platform-dependent precision

PHP uses double precision floating-point format (64-bit) which has 52-bits of significand precision. We gather 7 bytes of random data, and we fix the exponent to the bias (1023). In this way we generate a float of 1.mantissa.

Returns: float

getInteger()

Generate a random integer between $min and $max

Parameter Name Type Description
$min int
$max int

Returns: int

getString()

Generate a random string of specified length.

Uses supplied character list for generating the new string. If no character list provided - uses Base 64 character set.

Parameter Name Type Description
$length int
$charlist string|null

Returns: string

Top