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 trialLisa Rossiter
3,630 PointsI just cannot work this out
class Fish {
var $common_name;
var $flavor;
var $record_weight;
function __construct($name,$flavor,$record){
$this->name = $common_name;
$this->flavor = $flavor;
$this->record = $record_weight;
}
}
It sais be sure the $name is assigned to $commn_name
2 Answers
. Ali
9,799 Pointshi there,
I will try to make it simple for you ..
public class name {
var $firstName;
var $lastName;
function __construct ( $var1, $var2)
{
$this->firstName = $var1;
$this->lastName = $var2;
}
}
basically the variables that you have declared in the class , i.e $common_name, $flavor etc in the class (technically variables that you declare inside the class are called properties) , you are just reassigning their values to what user is putting in .. so for the class name
$lisa = new Name('Lisa','Roister');
I know that variables that you have to pass in the construct are the same that are declared in the class which makes it confusing ... hence now if you look at your code you will see where you making error. Sorry for the lame explanation. let me know if you not clear . cheers . Muhammad
Lisa Rossiter
3,630 PointsNo I got it, thanks for your very swift reply.