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 trialammarkhan
Front End Web Development Techdegree Student 21,661 Points$this in constructor
I am confused when $this->name = $name is used, because i cannot understand "name" used for reference, which element it is referring to? Is it the where we declared in start or function args?
Mai Lon Ross
5,891 PointsIn $this->name = $name , the first "name" is a property of the class, and the second "$name" is the variable value that you are assigning to it. $name could have been passed into the function, or declared within the class.
Ramiro Aguirre
Courses Plus Student 16,725 PointsRamiro Aguirre
Courses Plus Student 16,725 Pointseverything withing the __construct helps you set the parammetters for your methods in your class. for example