Tuesday, 15 May 2012

php - Incrementing a string producing unexpected results -


I was just playing with PHP, can someone tell me why the code below given 5566 instead of 6666 print Does it?

  $ a = 5; $ B = $ A; All alo $ a ++ $ B ++; Echo "\ n"; All alo $ a ++ $ B ++;   

Does it resonate $ 1 and add 1 to it? Why this result does not resonate?

Edit: Another simple example to look at:

  $ a = 5; $ B = $ A ++; All alo $ a ++ $ b;   

output 65

this When you put ++ after (suffix), it should be done after increments

  55 66   

The statement is executed. If you want

  66 66   

then do

  $ a = 5; $ B = $ A; Resonance ++ $ a ++ $ b; Echo "\ n"; All alo $ a ++ $ B ++;    

No comments:

Post a Comment