For example this:
var a = 123;
var b = a++;
now a
contains 124
and b
contains 123
Note that you can also write
b = ++a;
Which has the effect you are probably expecting.
It's important to realise that there are two things going on here: the assignment and the increment and the language should define in which order they will happen. As we have available both ++a
and a++
it makes sense that they should have different meanings.
For those of us from a C background, this is quite natural. If PHP behaves differently, we might be wondering why PHP chose to deviate from what we are accustomed to.