# 一个有关PHP引用传递的面试题，来看看吧。

**URL:** <https://www.shiqidu.com/t/topic/553>\
**Category:** 开发调优\
**Tags:** PHP\
**Created:** [2019 年2 月 24 日 16:49 UTC](https://www.shiqidu.com/t/topic/553 "2019-02-24T16:49:27Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

作者： ![Leon](https://www.shiqidu.com/user_avatar/www.shiqidu.com/leon/32/5_2.png) [@Leon](https://www.shiqidu.com/u/Leon)\
发布日期： [2019 年2 月 24 日 16:49 UTC](https://www.shiqidu.com/t/topic/553/1 "2019-02-24T16:49:27Z")

</div>

代码如下：

```php
$data = ['a', 'b', 'c'];

foreach ($data as $k => $v) {
    $v = &$data[$k];
}

```

问题：

1. 每次循环结束后变量`$data`的值是什么？
2. 程序执行完毕后变量`$data`的值是什么？
3. 请解释原因

---

<div class="post-metadata">

作者： ![yeqiu](https://www.shiqidu.com/user_avatar/www.shiqidu.com/yeqiu/32/14_2.png) [@yeqiu](https://www.shiqidu.com/u/yeqiu)\
发布日期： [2019 年2 月 25 日 01:46 UTC](https://www.shiqidu.com/t/topic/553/2 "2019-02-25T01:46:32Z")

</div>

最终结果$data = [b,c,c]
