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 (Retired) Classes and Objects Creating a Class and Defining an Object

Creating an object inside a class

I don't get it. What am I doing wrong. It asked me to create an object named "bluegill" as an instance of the class "Fish". Help. '''php <?php class Fish { $bluegill = new Fish; } ?> '''

3 Answers

Read the questions carefully. You are doing OK! Create the instance outside of the class.

Thanks, that worked! How do you know it's supposed to be outside the class? It said 'create an object named "bluegill" as an instance of the class "Fish".' What part of that is telling of where it goes?

I guess I said "Read the questions carefully" because it did not say to "create an object inside a class" as your tile suggests.

Ah, I see. Ok, well thanks for your help!

class Fish {}; $bluegill = new Fish;

This was a retarded question, the syntax wasn't covered in the lesson.