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) Properties and Methods Mid-Course Challenge

Help OOP

I have no idea what i am doing wrong and any help will be great

<?php

class Fish { public $common_name; public $flavor; public $something i forgot;

function__constructor($name, $flavor, $something){ <-- this is what i am messing up on and i dont know the problem

} }

5 Answers

Hello,

All that I see is wrong is the space needed between the word 'function' and the function name and the name of the class constructor (it's __construct not __constructor). Corey, he does not need to put the word 'public' before the function as if you do not provide the visibility of the function (public, private, protected) it automatically sets the visibility to public. Although, it is good practice, it isn't needed.

Cheers!

Corey Montgomery
Corey Montgomery
18,468 Points

Where are you hanging up? Trying to assign the class variables to those passed through the constructor?

Corey Montgomery
Corey Montgomery
18,468 Points

also is that code directly from the quiz?

If so, you need to add public before function and a space after 'function' before construct(). Also need to write 'construct'.

Need to see exactly what you are trying to submit to get a better idea.

Corey Montgomery
Corey Montgomery
18,468 Points

I agree about declaring it public. It is a habit I have gotten into. Shawn's post also explained the edits better than mine. The post erased my underscores and made it bold. I need to watch out for that.

I agree with what Shawn Gregory said. It's the space needed between function and __construct