Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

PHP Build a Simple PHP Application Working With Functions Displaying Only Four Shirts

Rifqi Fahmi
Rifqi Fahmi
23,164 Points

can anyone gimme references about += or -= or .=??

can anyone gimme references about += or -= or .=?? I need it for further reading. Thanks :)

2 Answers

1) the official documentation of assignment operators : http://php.net/manual/en/language.operators.assignment.php 2) official precedence documentation including easy links to more information :http://php.net/manual/en/language.operators.precedence.php 3) nice cheatsheet with examples from w3schools.com : http://www.w3schools.com/php/php_operators.asp

think that is all you need :-)

Software Singh
Software Singh
7,123 Points

Rifqui

what i understand by += , -= and *= is that when these operators are used then increment or decrement happens first.

To make it more simple lets take an example:-

i mostly use these operators in loops

so when we just want to make an increment or decrement in our loop by 1 (x+1) we write it as (x =+). what happens here is that first the loop prints 1 then 2 , 3 ,4 and so on... but when we use (x += ) then it prints 2 then 3,4,5 and so onn....

in simple words when we use =+ then increment happens first and then the output is given that why the first output we get is number 2. But on the other hand when we use =+ first it prints 1( initial value) then increment happens and it prints 2.

so, hope this helps you

happy coding...........

Rifqi Fahmi
Rifqi Fahmi
23,164 Points

I think you want to type "in simple words when we use += then increment happens first and then the output is given that why the first output we get is number 2" right ??? BTW thanks bro :)