Home  >  Article  >  Backend Development  >  Regarding the efficiency issue of php address reference

Regarding the efficiency issue of php address reference

不言
不言Original
2018-07-03 16:03:081676browse

This article mainly introduces the php address reference (the efficiency issue of php address reference), which has a certain reference value. Now I share it with you. Friends in need can refer to

php address reference. To share efficiency issues, friends who are learning PHP can take a look at

<?php 
echo &#39;begin time:&#39;.$begin=microtime(false).&#39;<br/>&#39;;//begin to count time 
$array=array(); 
for ($i=1;$i<=10000;$i++) {//产生一个很大的数组 
$array[$i]=$i; 
} 
/* 
$arr=$array;//拷贝 拷贝并打印总时间0.02 
foreach ($arr as $ar) { 
echo $ar.&#39;<br/>&#39;; 
} 
*/ 
/* 
$newarr=&$array;//地址引用 时间总是控制在0.01之内 地址引用的优势体现出来了 
foreach ($newarr as $r) { 
echo $r.&#39;<br/>&#39;; 
} 
*/ 
foreach ($array as $a) {//基本是0.02 很少是0.01 为什么没有地址引用的快呢?纳闷 
echo $a.&#39;<br/>&#39;; 
} 
echo &#39;end time:&#39;.$end=microtime(false).&#39;<br/>&#39;;//end to count time 
echo &#39;total time:&#39;.($end-$begin); 
?>

. The above is the entire content of this article. I hope it will be helpful to everyone’s learning. For more related content, please pay attention to the PHP Chinese website!

Related recommendations:

PHP encapsulated curl calling interface and introduction to common functions

About the php htmlentities() function Definition and usage

The above is the detailed content of Regarding the efficiency issue of php address reference. For more information, please follow other related articles on the PHP Chinese website!

Statement:
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