Welcome to the Treehouse Community
The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Alejandro Hernandez
7,629 PointsOOPHP Course - Not sure what i am doing wrong here...
<?php
class Fish {
public $common_name;
public $flavor;
public $record_weight;
function __construct($name, $flavor, $record)
{
this->common_name = $name;
this->flavor = $flavor;
this->record_weight = $record;
}
}
?>
5 Answers

Mike Costa
Courses Plus Student 26,361 PointsPHP variables need the $ in front of them. For objects, to access the member variables within a class, you would need $this->commonname, $this->flavor, ect ect.

Alejandro Hernandez
7,629 PointsNo Luck w/that.
<?php
class Fish {
public $common_name;
public $flavor;
public $record_weight;
public function __construct($name, $flavor, $record)
{
this->common_name = $name;
this->flavor $flavor;
this->record_weight = $record;
}
}
?>

Philip Cox
14,818 PointsNot an answer. But here is a great article on beginning OOP in PHP. http://code.tutsplus.com/tutorials/object-oriented-php-for-beginners--net-12762

Michael Collins
433 PointsIf you are trying to get a lesson to accept this an answer, I can't help with that. But if you describe what you want your code to do and what is and is not doing, I can help with that.

Mike Costa
Courses Plus Student 26,361 PointsPHP variables need the $ in front of them. For objects, to access the member variables within a class, you would need $this->commonname, $this->flavor, ect ect.

Alejandro Hernandez
7,629 PointsGood call Mike. Thnx a million.
Philip Cox
14,818 PointsPhilip Cox
14,818 PointsHi. This is just a guess. Do you need to set your function as public and also return it?