Some reminiscences, some memories
Just another boring day

July 3, 2008

PHP —— 为什么不要在 foreach 中使用变量引用

Filed under: PHP — Tags: , , — mikespook @ 2:14 am

最近在浏览同事之前写的代码的时候,发现大量的变量引用使用在 foreach 中:

1 <?php

2 $a = array(a‘, ‘b‘, ‘c‘, ‘d);

3 foreach($a as &$v) {

4 $v = $v ._bar‘;

5 }

6 var_dump($a);

(more…)

Powered by WordPress 沪ICP备05006454号