References

I've been looking for references on PHP references.

References are discussed a bit here and there, but their use isn't detailed that well. In PHP5, everything returns a reference, Java style, but in PHP4, you need to be explicit. The issue, as with other languages, is where you put your &, and when.

PHP References by John Coggeshall is a beginning article, and has good examples.

Advanced PHP References by John Coggeshall shows how to write a function that returns a reference, and how to deal with PHP = assignment operator. (PHP sucks in that way.)

Synopsis: The =& operator indicates that the scalar on the left will contain a reference. This means that for $a =& foo();, foo() must return a reference, and that $a contains a reference. Subsequent use of $a will be dereferenced automatically.

When creating objects, use the =& assignment operator instead of the = assignment operator. Using the = operator causes a copy of the object to be created, increasing memory use and decreasing speed.

.