Friday 15 August 2014

Php post/pre increment/decrement, precedence -


As I know, preincrement is calculated before all other functions, calculating post-progression after all operations She goes.

In PHP documents it is said that there is a lot of priority in growth (as I consider to be a pre-pay increase), post-arrangement should have very little priority, in fact, the lowest one

+ operator priority is too high then ++ one (according to the docs).

So, now the question is: An example in Php docs, which indicates that preference and postcure may vary in an expression:

  // mix ++ and + Undefined behavior produces $ a = 1; Resonance ++ $ a + $ a ++; // 4 or 5 can print   

Why? WTF? I look at the following scenario, it is very clear:

  1. Calculate the sum for $ ainetrack $ a
  2. $ a and $ a
  3. $ A

    I do not understand why this may not be so. The PHP documentation (and also an example) about this topic can be found there:

    This is always 4 is using post-pay increase to build the last $ a 5 , then Pre-pay Scale as before $ a

      $ a = 1; Resonance ++ $ a + $ a ++; // 4   

    and

      $ a = 1; Re: ++ $ a + ++ $ a; // 5   



No comments:

Post a Comment