1147. Class

1147.1. Zend\Math\Rand

Pseudorandom number generator (PRNG)

1147.1.1. Methods

1147.1.1.1. getBytes

getBytes()

Generate random bytes using OpenSSL or Mcrypt and mt_rand() as fallback

Parameters:
  • integer
  • bool – true if you need a strong random generator (cryptography)
Return type:

string

Throws :

ExceptionRuntimeException

1147.1.1.2. getBoolean

getBoolean()

Generate random boolean

Parameters:bool – true if you need a strong random generator (cryptography)
Return type:bool

1147.1.1.3. getInteger

getInteger()

Generate a random integer between $min and $max

Parameters:
  • integer
  • integer
  • bool – true if you need a strong random generator (cryptography)
Return type:

integer

Throws :

ExceptionDomainException

1147.1.1.4. getFloat

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.

Parameters:bool – true if you need a strong random generator (cryptography)
Return type:float

1147.1.1.5. getString

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.

Parameters:
  • integer
  • string|null
  • bool – true if you need a strong random generator (cryptography)
Return type:

string

Throws :

ExceptionDomainException

Project Versions

Table Of Contents

Previous topic

1146. Class

Next topic

1148. Class

This Page