Re: Copy On Write and Assign By Reference perform different on PHP5 and PHP7
| From: | Sara Golemon | Date: | Fri, 01 Apr 2016 01:52:24 +0000 |
| Subject: | Re: Copy On Write and Assign By Reference perform different on PHP5 and PHP7 | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-92059@lists.php.net to get a copy of this message | ||
On Thu, Mar 31, 2016 at 9:47 AM, Huqiu Liao <liaohuqiu@gmail.com> wrote:
> I have a question about Assign By Reference and I posted on StackOverflow,
> I'd like to know the reason behind it, and I did not get any this kind of
> answer, can anyone give me some clues.
>
Are you asking out of curiosity? Or because you think a new bug has
been introduced in PHP7?
If the latter, I'd respond by pointing out that the behavior of using
multiple operations with side-effects (like pre/post inc/dec) is
defined as undefined. That is, while the PHP reference implementation
may give you a particular result, you should not rely on that result.
If the former, and you're just curious why, it comes down to a very
fundamental change in the way PHP7 deals with references. I'd
recommend reading Nikita's writeup of the differences between PHP 5
and PHP 7 variables at:
https://nikic.github.io/2015/05/05/Internal-value-representation-in-PHP-7-part-1.html
-Sara