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 trialammarkhan
Front End Web Development Techdegree Student 21,661 PointsCannot pass the challenge Task3.
While in my opinion, i am doing this right, why isn't it working?
<?php
class Fish {
var $common_name;
var $flavor;
var $record_weight;
function __construct($name,$flavor,$record){
$name = $common_name;
$flavor = $flavor;
$record = $record_weight;
}
}
?>
2 Answers
Pedro Garcia
8,426 PointsHi Ammar, It seems you're not declaring your variables in the correct way. You are using var instead of public. Also, when assigning values in the construct you should use the $this-> constructor. It should look something 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;
}
}
?>
Hope this helps you. Sorry about my english. Pete
ammarkhan
Front End Web Development Techdegree Student 21,661 PointsThanks