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 trialJon Niu
2,843 PointsCreating 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
Leonardo Hernandez
13,798 PointsRead the questions carefully. You are doing OK! Create the instance outside of the class.
MUZ1407800 Doubt Milazi
11,813 Pointsclass Fish {}; $bluegill = new Fish;
marcuskage
1,454 PointsThis was a retarded question, the syntax wasn't covered in the lesson.
Jon Niu
2,843 PointsJon Niu
2,843 PointsThanks, 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?
Leonardo Hernandez
13,798 PointsLeonardo Hernandez
13,798 PointsI guess I said "Read the questions carefully" because it did not say to "create an object inside a class" as your tile suggests.
Jon Niu
2,843 PointsJon Niu
2,843 PointsAh, I see. Ok, well thanks for your help!