In this post, we will go through the process of deep copying a PHP variable in user land (i.e., in pure PHP) step by step, describing the challenges facing every step, resolving them and going forward. (TL;DR: check this Github gist for the final solution) The Challenges There are three particular challenges for solving the deep copy problem in PHP: Some things simply can not be copied (e.g., resources like file handles, and objects like MySQLi instances) References are invisible in PHP. They …