Caution: This documentation is for eZ Publish legacy, from version 3.x to 6.x.
For 5.x documentation covering Platform see eZ Documentation Center, for difference between legacy and Platform see 5.x Architecture overview.

rand

Summary

Returns a random integer.

Usage

rand( [min_val, max_val] )

Parameters

NameTypeDescriptionRequired
min_val integer Lower limit (inclusive). No.
max_val integer Upper limit (inclusive). No.

Returns

Integer.

Description

This operator returns a random integer. The optional parameters "min_val" and "max_val" can be used to control the range from which the random number is picked. If you want a random integer between 3 and 13 (inclusive), use (3, 13) as parameters.

Examples

Example 1

rand()

Returns a random integer.

Example 2

rand( 5 )

Returns a random integer that is greater than 4.

Example 3

rand( 3, 13 )

Returns a random integer that is greater than 2 and less than 14.

Balazs Halasy (16/06/2006 7:48 am)

Balazs Halasy (16/06/2006 8:10 am)


Comments

  • Default

    What is the default range?
    • Re: Default

      The PHP function used for this template operator is mt_rand().

      The default range is then 0, RAND_MAX, where RAND_MAX is an environment-dependant constant.

      I tried the function 18000 times, and the max I obtained was 2147330140.

      Hope it helps.