Question:What will the following script output?<?php
$array = '0123456789ABCDEFG';
$s = '';
for ($i = 1; $i < 50; $i++) {
$s .= $array[rand(0,strlen ($array) - 1)];
}
echo $s;
?>
A A string of 50 random characters
B A string of 49 copies of the same character, because the random number generator has not been initialized
C A string of 49 random characters
D Nothing, because $array is not an array
E A string of 49 ‘G’ characters
+ ExplanationThe correct answer is C. As of PHP 4.2.0, there is no need to initialize the random number generator using srand() unless a specific sequence of pseudorandom numbers is sought.