Rapide Advanced Adulte
 
 Web|Image|Shop|Video|News|Wmx|Mobile|Wiki|Ajouter ce moteur

     Manuel PHP     
Partager
 
 
Partager
Partager

 

Table :

.abs
.acos
.acosh
.asin
.asinh
.atan2
.atan
.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
.log10
.log1p
.log
.max
.min
.mt getrandmax
.mt rand
.mt srand
.octdec
.pi
.pow
.rad2deg
.rand
.round
.sin
.sinh
.sqrt
.srand
.tan
.tanh
 
   

  rand  


rand

(PHP 3, PHP 4, PHP 5)

rand -- Génère une valeur aléatoire

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).

Exemple 1. Exemple avec rand()

<?php
echo rand() . "\n";
echo
rand() . "\n";

echo
rand(5, 15);
?>

L'exemple ci-dessus va afficher quelque chose de similaire à :

7771
22264
11

Note : Sur quelques plate-formes (comme Windows par exemple), RAND_MAX est limité à 32768. Si vous désirez une limite supérieure à 32768, en spécifiant min et max, vous serez autorisés à utiliser un intervalle plus grand que RAD_MAX, ou bien, utilisez la fonction mt_rand() à la place.

Note : Depuis PHP 4.2.0, vous n'avez plus besoin d'initialiser le générateur de nombres aléatoires avec srand() ou mt_srand() car c'est fait automatiquement.

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(), mt_rand() et getrandmax().


    Annonces       
 

 Retour au chapitre Php

 

Top
 

Ajouter JungleKey.fr à votre Explorateur

 
 

About Us | © 2007 JungleKey




iBlack | Mobile | Wiki | Ajouter ce moteur
.