Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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 :)