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 Object-Oriented PHP Basics Building the Recipe Static Methods

Alex Flores
Alex Flores
7,864 Points

How is she calling a method from another class inside the Render class?

I don't really understand how this works. She's calling the getTitle() method from the Recipe class within the Render class. She's not including the Recipe class or anything. Why is this working?

Is it because she's pulling the object $recipe1, which is an object from the Recipe class and therefore she has access to all of the Recipe class methods?

Thanks

1 Answer

andren
andren
28,558 Points

Is it because she's pulling the object $recipe1, which is an object from the Recipe class and therefore she has access to all of the Recipe class methods?

Yes, that is more or less correct. An instance of a class has access to all of the methods declared within the class that are marked as public.