Regarding the efficiency issue of php address reference

不言
Release: 2023-04-02 09:04:02
Original
1655 people have browsed it

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); 
?>
Copy after login

. 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!

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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!