php地址引用(php地址引用的效率问题)_php技巧

WBOY
Release: 2016-05-17 09:11:58
Original
867 people have browsed it
复制代码 代码如下:

echo 'begin time:'.$begin=microtime(false).'
';//begin to count time
$array=array();
for ($i=1;$i$array[$i]=$i;
}
/*
$arr=$array;//拷贝 拷贝并打印总时间0.02
foreach ($arr as $ar) {
echo $ar.'
';
}
*/
/*
$newarr=&$array;//地址引用 时间总是控制在0.01之内 地址引用的优势体现出来了
foreach ($newarr as $r) {
echo $r.'
';
}
*/
foreach ($array as $a) {//基本是0.02 很少是0.01 为什么没有地址引用的快呢?纳闷
echo $a.'
';
}
echo 'end time:'.$end=microtime(false).'
';//end to count time
echo 'total time:'.($end-$begin);
?>
Related labels:
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