In a few different places I saw comments about my last blog post about references and
performance where commentators noted that my example was
pointless. Which of course is true and to some degree the
point.
I read a lot of PHP code and from time to time I see people with
a non-PHP background (or otherwise influenced) putting references
everywhere they pass arrays or such in order to prevent copies. I
knew this was a bad practice in PHP 5 and wanted to verify this
in PHP 7. For readers with a stronger PHP background this doesn't
come to mind and so comments are like "what if I want to modify
the data?" which might lead to something like this:
function modify(&$data) { $data["foo"] = "bar"; } $data = [ /* huuuuuge array */ ]; modify($data);
In this code, from a performance perspective, the reference likely …
[Read more]