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 trialJames Lambert
Courses Plus Student 14,477 PointsPHP Object oriented challenge when you get to the __construct section doesn't work
Any one else having problems with this quiz?
class Fish { public $common_name = 'default_name'; public $flavor = 'default_flavor'; public $record_weight = 0;
function __construct($name, $flavor, $record){ $this->name = $common_name; $this->flavor = $flavor; $this->record = $record_weight; }
This works on my server but not in the quiz. The quiz keeps telling me to use $this->name = $common_name which I have.
<?php
class Fish {
public $common_name = 'default_name';
public $flavor = 'default_flavor';
public $record_weight = 0;
function __construct($name, $flavor, $record){
$this->name = $common_name;
$this->flavor = $flavor;
$this->record = $record_weight;
}
}
?>
1 Answer
Paul Ryan
4,584 PointsYou seem to be setting the variables the wrong way around.
<?php
class Fish {
public $common_name = 'default_name';
public $flavor = 'default_flavor';
public $record_weight = 0;
function __construct($name, $flavor, $record){
$this->common_name = $name;
$this->flavor = $flavor;
$this->record_weight = $record;
}
}
?>
the above should work.
Any questions just ask.
James Lambert
Courses Plus Student 14,477 PointsJames Lambert
Courses Plus Student 14,477 PointsYep. Thanks. I see what I did.