Copying PHP Objects

When working with PHP object-oriented programming, the concept of creating copies of objects you’ve created can be a little confusing. The main thing you need to understand is that PHP objects are passed byref rather than the standard variable behavior of passing elements byval.

In case you have never heard those terms before, byref means “by reference,” which means that you are essentially assigning an additional name to your original variable. ByVal means “by value,” which means that you are actually copying the variable, creating an entirely new instance of it.