mt_getrandmax <<< |
mt_rand | mt_srand >>> |
6.18 Mathématiques 6 Référence des fonctions Manuel PHP . Introduction . Pré-requis . Installation . Configuration à l'exécution . Types de ressources . Constantes pré-définies . abs . acos . acosh . asin . asinh . atan . atan2 . atanh . base_convert . bindec . ceil . cos . cosh . decbin . dechex . decoct . deg2rad . exp . expm1 . floor . fmod . getrandmax . hexdec . hypot . is_finite . is_infinite . is_nan . lcg_value . log . log10 . log1p . max . min . mt_getrandmax ->mt_rand . mt_srand . octdec . pi . pow . rad2deg . rand . round . sin . sinh . sqrt . srand . tan . tanh |
6.18.41 mt_rand() Génère une valeur aléatoire (meilleure méthode)[ Exemples avec mt_rand ] PHP 3 >= 3.0.6, PHP 4, PHP 5 int mt_rand ( int min , int max )De nombreux générateurs de nombres aléatoires provenant de vieilles bibliothèques libcs ont des comportements douteux et sont très lents. Par défaut, PHP utilise le générateur de nombres aléatoires de libc avec la fonction rand . mt_rand est une fonction de remplacement, pour cette dernière. Elle utilise un générateur de nombres aléatoire de caractéristique connue, le " Mersenne Twister " qui est 4 fois plus rapide que la fonction standard libc. La "Homepage of the Mersenne Twister " est http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/emt.html . Appelée sans les arguments optionnels min et max , mt_rand retourne un nombre pseudo-aléatoire, entre 0 et RAND_MAX . Pour obtenir un nombre entre 5 et 15 inclus, il faut utiliser mt_rand(5,15) .
Voir aussi mt_srand , mt_getrandmax et rand . |
<< | mt_rand | >> |
mt_getrandmax | Mathématiques | mt_srand |