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 trialAlejandro 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,362 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,362 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?