Odi's astoundingly incomplete notes

New entries | Code

Why PHP References are crap

$iterator =& $queue->iterator();
$list = array();
while ($iterator->hasNext()) {
  $obj =& $iterator->getNext();
  $list[] =& $obj;
Will not do what you expect. It will merely screw up all the objects in $queue. $list[] will then contain n identical references to the last object. Yes PHP guys, you really make my day.
posted on 2004-12-22 10:50 UTC in Code | 0 comments | permalink