Home > Backend Development > PHP Tutorial > 为什么此段PHP foreach 时打印的值是这样?

为什么此段PHP foreach 时打印的值是这样?

WBOY
Release: 2016-06-06 20:11:52
Original
1033 people have browsed it

为什么此段PHP foreach 时打印的值是这样?

输出分别为2,2,2

好像既没有发生写时复制也没有发生强制分裂吧?
求解惑
PHP版本5.6

回复内容:

为什么此段PHP foreach 时打印的值是这样?

输出分别为2,2,2

好像既没有发生写时复制也没有发生强制分裂吧?
求解惑
PHP版本5.6

深入探讨php的foreach
https://segmentfault.com/a/1190000004340...

foreach循环时调用current等函数
https://segmentfault.com/a/1190000004340...

current是引用传参

这个涉及到指针和源码的结构体属性了,建议你去看下这个文章:关于current和遍历导致的问题

Related labels:
c php
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