+ 3
I can not understand this ?
$a=2; $b=$a++ Echo $b; The answer is 2 How its does please describe
6 odpowiedzi
+ 11
Its because your assigning the value of $a before its incremented by 1 try assigning ++$a if your expecting 3.
$a++ means use the value of $a and then incremenet by one
++$a means incremnet $a by 1 and use it
+ 9
increment: ++, and decrement: --, operators.
• These operators can be placed before or after the variable expression they modify.
• If they are placed before (a prefix operator), they modify the variable expression before its value is used.
• If they are placed after (a postfix operator), they modify the variable expression after its value is used.
• The prefix and postfix increment both increase the value of a number by 1.
• The only difference between the two is their return value. The former increments (++) first, then returns the value of x, thus ++x. The latter returns the value of x first, then increments (++), thus x++.
+ 4
I've suffered a same type of confusion but in other language.
Hope it will help you and please use the search bar before posting any questions. Happy coding....
https://www.sololearn.com/discuss/1714986/?ref=app
+ 1
Thank you all guys i got answer