Php Chinese network (www.php.cn) provides the most comprehensive basic tutorial on programming technology, introducing HTML, CSS, Javascript, Python, Java, Ruby, C, PHP, basic knowledge of MySQL and other programming languages. At the same time, this site also provides a large number of online instances, through which you can better learn programming... Reply: Do not discuss undefined behaviors.
PHP: Operator Precedence
First, you need to know about reference counting and variable separation in the php source code. Then let's take a look at opcode:
line #* E I O op fetch ext return operands------------------------------------------------------------------------------------- 3 0 E > ASSIGN !0, 1 4 1 ASSIGN_REF !1, !0 5 2 PRE_INC $2 !0 3 PRE_INC $3 !0 4 ADD ~4 $2, $3 5 PRE_INC $5 !0 6 ADD ~6 ~4, $5 7 ASSIGN !2, ~6 6 8 SEND_VAR !2 9 DO_FCALL 1 'var_dump' 10 > RETURN 1
This can be said to be a bug in PHP 7 or earlier versions. why not explain it? Is 7 different from 5? Php7,
$ A = 1; $ B = & $ a; $ c = (++ $ a) + (++ $ ); the result $ c is 9. In php5, the result is 10.Php5:
$ A = 1; $ B = & $ a; $ c = (++ $ a) + (++ $ ); // $ c = 10
$ A = 1; $ B = & $ a; $ c = (++ $ a); // $ c = 2
$ A = 1; $ B = & $ a; $ c = (++ $ a) + (++ $ a); // $ c = 6
In php7, $ a = 1; $ B = & $ a; $ c = (++ $ a) + (++ $ ); the result $ c is 9.