Understanding References and Copies in PHP

By Marian Pop

I spent hours debugging a problem that came down to a single character. A function was modifying an array that should have been unchanged. I checked everything from the function logic, the calling code, to the data itself. Everything looked correct. Finally, I spotted an ampersand in the foreach loop from code I’d written months earlier and forgotten about – hours for one character. by Marian Pop

This article was originally published in the March 2026 issue of php[architect] magazine. To read the complete article please subscribe or purchase the complete issue.

Leave a comment

Use the form below to leave a comment: