SommaireTelecharger la documentationChapitre suivantChapitre precedent  

  .: News :.: Edito :.: Scripts :.: Forum :.: Erreurs :.: Jobs :. 
 
Sommaire

Mathématiques

Introduction
Abs
Acos
acosh
Asin
asinh
Atan
Atan2
atanh
base_convert
BinDec
Ceil
Cos
cosh
DecBin
DecHex
DecOct
deg2rad
Exp
Floor
getrandmax
hexdec
lcg_value
Log
Log10
max
min
mt_rand
mt_srand
mt_getrandmax
number_format
OctDec
pi
pow
rad2deg
rand
round
Sin
sinh
Sqrt
srand
Tan
tanh

6.50.36 rand

[ Exemples avec rand ]   PHP 3, PHP 4 >= 4.0.0

Description

int rand(int min ,int max )

Appelée sans les options min et max, rand retourne un nombre pseudo-aléatoire entre 0 et RAND_MAX. Si vous voulez un nombre aléatoire entre 5 et 15 (inclus), par exemple, utilisez rand (5, 15).

N'oubliez pas d'initialiser le générateur de nombres aléatoires avec srand.

Note

Dans les versions antérieures à la 3.0.7 la signification du paramètre max était longueur. Pour avoir le même résultat, il faut utiliser mt_rand (5, 11) pour obtenir un nombre aléatoire entre 5 et 15.

Voir aussi srand, getrandmax, mt_rand, mt_srand et mt_getrandmax.


Chapitre précédentChapitre suivantAccueil nexen.net