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 trial2 Answers
Niki Molnar
25,698 Points-> is called the object operator and is used in objects to access the methods and properties of that object. At its basic level, it gets or sets an object variable within a class or other object, e.g. an array. The object is always on the left hand side, before the ->
$foo->bar(); // Calls a function called bar() within the object $foo
$foo->bar = 'Jim'; // Accesses a property called bar in the object $foo and sets it to Jim
Ezra Siton
12,644 PointsThe answer above.
In general : Its hard to 100% understand this issue without some OOP knowledge:
Related treehouse course:
https://teamtreehouse.com/library/objectoriented-php-basics-2 https://teamtreehouse.com/library/objectoriented-php-basics-2/understanding-classes/accessing-methods
In other Programming languages you find the use of dot (.) instead of ->.(If you know the consept of dot maybe it will help you to understand this issue)
// javascript
Math.random();
Related links:
https://stackoverflow.com/questions/14037290/what-does-this-mean-in-php-or