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

Create an object named "bluegill" that is an instance of our Fish class.

<?php

class Fish {

$bluegill = new Fish();

}

?>

Am I doing something wrong? Bluegill is an object, which is an instance of the Fish class - right?

12 Answers

Don't worry, like an idiot I had it stuck in between the parentheses...

I have Joined this exceptional group of individuals that put the code in the parentheses :) Never a prouder moment !

I clearly got it when you said like an #Idiot... for sure

not an idiot, just learning... no one is above simple mistakes.

Marius Mirzac
Marius Mirzac
5,970 Points

<?php

class Fish {

}

$bluegill = new Fish();

?>

thx man :)

Move the closing closing curly bracket to the line above $bluegill and it should pass.

Im having the same problem :(

<?php

class Fish {

$bluegill = new Fish(); }

?>

Hey tomp ,

Thank you . it was driving me mad haha. I feel stupid now :)

cheers for the help

No worries, it's not easy, this course!

we will be php ninja's in no time tomp :)

Konrad Pilch
Konrad Pilch
2,435 Points

xddd

When learning, i think everyone are stupid in the subject thier just learning. Why? because they dont know anythng about it so in suciety thier owul dbe stupid i believe.

When learning somehitng , the more you fail , the better because the more experience you got .

If you keep doing on thing, over 10 year, and the guy says he has 10 years of programming eperience, and the other guy had only 1 year of programming experience, the 10year old guy, has the same level of programming experience x10 . SO thats the same as the new one.

If you want to succeed : failiture and learning comes before success and wealth :)

Keep it up :)

Lal this was over a year ago. You can tell me your story how it went till now :D

<?php

class Fish { }

$bluegill = new Fish();

?>

Betsabeh Yeganeh
Betsabeh Yeganeh
3,793 Points

<?php class Fish{

} $bluegill = new Fish(); ?>

Mine works with <?php

class Fish {

}

$bluegill = new Fish();

?>