Home > Backend Development > PHP Tutorial > PHP address reference (efficiency issue of PHP address reference)_PHP tutorial

PHP address reference (efficiency issue of PHP address reference)_PHP tutorial

WBOY
Release: 2016-07-21 15:19:51
Original
833 people have browsed it

Copy 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 Very large array
$array[$i]=$i;
}
/*
$arr=$array;//Total copy and print time 0.02
foreach ($ arr as $ar) {
echo $ar.'
';
}
*/
/*
$newarr=&$array;//Address reference The advantage of address reference that time is always controlled within 0.01 is reflected in
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);
?>

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/325221.htmlTechArticleCopy the code as follows: ?php echo 'begin time:'.$begin=microtime(false).'br /';//begin to count time $array=array(); for ($i=1;$i=10000;$i++) {//Generate a large array $arra...
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template