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 trialMoises Miguel
5,028 PointsDefine a constructor on the Fish class with 3 parameters, in order, named $name, $flavor, and $record.
I have absolutely no idea what the problem is here. What can you guys tell me is wrong with my code?
<?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;
}
?>
2 Answers
Hugo Paz
15,622 PointsHi Moises,
Looking at it I believe is the fact that theres no space between function and __constructor and you didnt put the constructor inside the class.
Try it like this
<?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;
}
}
?>
Moises Miguel
5,028 PointsYeah you were right on both of those, Thanks!