srand


qr-code apg

GENERATES a seed for the random number generator.

Seeds the random number generator with seed or with a random value if no seed is given.




RANDOM NUMBERS

are numbers that occur in a sequence such that two conditions are met:

1 . the values are uniformly distributed over a defined interval or set.
2 . it is impossible to predict future values based on past or present ones.

Random numbers are important in statistical analysis and probability theory.

There is no need to use  srand  as this is done automatically when we need to seed the random number generator.

Since PHP 7.1.0,  srand  becames an alias of  mt_srand .



<?php

void srand 
( int $seed = ? )

where,

$seed = Arbitrary INTEGER value to be used as seed

?>

$seed


Arbitrary INTEGER value to be used as seed.



  1 EXERCISE   

<?php
 
$srd01  
= srand();

var_dump($srd01);

?> 

 RESULT   

NULL

... is returned

  2 EXERCISE   

<?php

$seed02 
= 100;
 
$srd02  = srand($seed02);

var_dump($srd02);

?> 

 RESULT   

NULL

... is returned