First, $counter is incremented by the ++ operator, thus ($counter == 1). Next, the original value of $counter (that is, 0) is returned by the ++ operator. Then that value is assigned to $counter by the = operator.

Let's look at it again with the working statement:

$counter++;

First, $counter is incremented by the ++ operator, thus ($counter == 1), just as before. Next, the original value of $counter (that is, 0) is returned by the ++ operator, just as before. However, that original value is then ignored, instead of being assigned to $counter the way it was before.