Copy the code The code is as follows:
echo 'begin time:'.$begin=microtime(false).'
';//begin to count time
$ array=array();
for ($i=1;$i<=10000;$i++) {//Generate a large array
$array[$i]=$i;
}
/*
$ arr=$array;//Total copy and print time 0.02
foreach ($arr as $ar) {
echo $ar.'
';
}
*/
/*
$newarr= &$array;//The address reference time is always controlled within 0.01. The advantage of address reference is reflected
foreach ($newarr as $r) {
echo $r.'
';
}
*/
foreach ($array as $a) {//Basically 0.02, rarely 0.01 Why is it not as fast as address reference? Wondering
echo $a.'
';
}
echo 'end time:'.$end=microtime(false).'
';//end to count time
echo 'total time:'.($end-$begin);
?>
The above has introduced the efficiency issues of the PHP address reference of the efficiency source hard disk bad sector detection software, including the content of the efficiency source hard disk bad sector detection software. I hope it will be helpful to friends who are interested in PHP tutorials.