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 trial![](https://ecs-static.teamtreehouse.com/assets/views/marketing/shared/community-banner-white-47072046c51352fe6a69f5e691ff5700b28bb11d45197d7bdf066d9ea3f72d0c.webp)
![Luke Briedis](https://secure.gravatar.com/avatar/9027c3cf7de6fbd5f141e66b775c230e?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Luke Briedis
3,600 PointsPHP OO Basics 6/7 final challenge not passing
Not sure why this isn't passing. It's 1:1 with the examples used in the videos. I even tried using the echoing what the proposed example is, though it shouldn't require that exactly right ?
Add a getInfo method to your Trout class that returns a string containing the common_name, flavor, record_weight, and species properties. For example, on our brook trout it might return "Brook Trout tastes Delicious. The record Brook Trout weighed 14 pounds 8 ounces."
<?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;
}
public function getInfo() {
$output = "The {$this->common_name} is an awesome fish. ";
$output .= "It is very {$this->flavor} when eaten. ";
$output .= "Currently the world record {$this->common_name} weighed {$this->record_weight}.";
return $output;
}
}
class Trout extends Fish {
public $species;
public function __construct($name, $flavor, $record, $species) {
parent::__construct($name, $flavor, $record);
$this->species = $species;
}
public function getInfo() {
return $this->species . $this->name . "tastes" . $this->flavor . ". " . "The record" . $this->species . $this->name . "weighed" . $this->record . ".";
}
}
$brook_trout = new Trout("Trout", "Delicious", "14 pounds 8 ounces", "Brook");
?>
10 Answers
![Hampton Paulk](https://secure.gravatar.com/avatar/d9ce681eec69b47f67e52f86526255ec?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Hampton Paulk
5,093 Pointshint for ya: public $common_name; is the actual property we want.
![Brian Molkovich](https://uploads.teamtreehouse.com/production/profile-photos/369212/micro_EqLRdD66OcE.jpg)
Brian Molkovich
11,333 PointsI got right answer, if somebody needs)))
![Stewart Anderson](https://secure.gravatar.com/avatar/52a1e11ea911737191551d0e4992a3a5?s=60&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Stewart Anderson
10,329 PointsI do. The "Bummer. Try again!" message seems to be the only "guidance" offered here. So frustrating.
![Jorge Talancon](https://secure.gravatar.com/avatar/42cd8e80623fe78d82b1202dd6f6cd71?s=60&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Jorge Talancon
5,416 PointsStewart. I use sublime text on localhost to check out my errors. Because you do get a lot more information about your mistakes. Hope this tip works for you!
Denford Gudyanga
5,420 Pointspublic function getInfo() { return $this->species . $this->common_name . " tastes " . $this->flavor . ". The record " . $this->species . $this->common_name . " weighed " . $this->record_weight . ".";
}
![Elijah Collins](https://uploads.teamtreehouse.com/production/profile-photos/91091/micro_1465210_10202875929167122_1256193075_n__1_.jpg)
Elijah Collins
19,457 Points<?php
public function getInfo() {
return $this->species . $this->common_name . " tastes " . $this->flavor . ". The record " .
$this->species . $this->common_name . " weighed " . $this->record_weight . ".";
}
?>
![Luke Briedis](https://secure.gravatar.com/avatar/9027c3cf7de6fbd5f141e66b775c230e?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Luke Briedis
3,600 PointsIc. Then I also have to use $record_weight instead of $weight. This is confusing, because in the earlier lesson, $weight becomes the variable for $record_weight, but upon reflection it was not extended this far in the lesson. One would just assume it would be addressed the same, I guess I know better now.
![Grant LeMahieu](https://uploads.teamtreehouse.com/production/profile-photos/213722/micro_grant_city1.jpg)
Grant LeMahieu
11,301 PointsI used the syntax in the parent class getInfo. Hint: name and species together
![Eric Jackson](https://secure.gravatar.com/avatar/fe1b527e83432a4aa89d832e733d9e30?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Eric Jackson
7,502 PointsI can't pass this. My code:
public function getInfo() { $output = "The {$this->species} is an awesome fish. "; $output .= "It is very {$this->flavor} when eaten. "; $output .= "Currently the world record {$this->common_name} weighed {$this->record_weight}."; return $output;
Any thoughts? Thanks.
![Eric Jackson](https://secure.gravatar.com/avatar/fe1b527e83432a4aa89d832e733d9e30?s=60&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Eric Jackson
7,502 PointsNevermind, was missing a bracket.
![Steve Berrill](https://secure.gravatar.com/avatar/f90ba874b58e8f71a3075aa7a41f5a36?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Steve Berrill
20,016 PointsHeres what I did
public function getinfo() {
return $this->species . $this->common_name . "tastes" . $this->flavor . ". The record" . $this->species . $this->common_name . "weighed" . $this->record_weight;
}
I actually struggled because I forgot to close the function!
![Wouter Delken](https://secure.gravatar.com/avatar/fbc073e8baa4cd7e18ea17f0df51e5b0?s=60&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Wouter Delken
3,553 PointsCan't believe it, I also forgot to close the function! Caught it now, so thanks for your comment :-)
![Echo Yang](https://secure.gravatar.com/avatar/483f8d8e4ac8e6f5fb184c81952b961c?s=60&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Echo Yang
6,740 PointsAlso can't believe it... I tried many times and finally found forget to close it....
![Jeremiah Wodke](https://secure.gravatar.com/avatar/c0566c903c11dc8130adaea3da66762d?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Jeremiah Wodke
3,192 PointsI know I'm way off but I don't understand why. Can somebody help me pass this brutal Quiz? lol
$brook_trout = new Trout("Trout", "Delicious", "14 pounds 8 ounces", "Brook"){
function __construct{
$this->Trout = $common_name;
$this->Delicious = $flavor;
$this->14_pounds_8_ounces = $record_weight;
$this->Brook = $species;
};
public function getInfo($common_name, $flavor, $record_weight, $species) {
$output = "The $common_name tastes $flavor. The record $species $common_name weighed $record_weight.";
return $output;
}
};
![Hampton Paulk](https://secure.gravatar.com/avatar/d9ce681eec69b47f67e52f86526255ec?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Hampton Paulk
5,093 PointsThe names of the arguments that you use in the construct are irrelevant, only the property name matters. However, you do need to name them with some level of readability.
for an example (this works but is not really readable to someone who did not write it):
public function __construct($arg1, $arg2, $arg3, $arg4) {
parent::__construct($arg1, $arg2, $arg3);
$this->species = $arg4;
}
![Juan Jimenez](https://secure.gravatar.com/avatar/1fc3ef4deea3b22c1a696276a87d52d1?s=60&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Juan Jimenez
11,245 PointsI can't get it to pass following this example
class Trout extends Fish {
public function __construct($name, $flavor, $record, $species) {
parent::__construct($name, $flavor, $record);
$this->species = $species;
}
}
James Gill
Courses Plus Student 34,936 PointsJames Gill
Courses Plus Student 34,936 PointsIt's the actual property that we want where, exactly? This doesn't make sense to me in the context of this problem step.
[UPDATE] Ah, I figured it out. Later in the output string, we don't explicitly output the name and species, we just return the "common_name". I think what confuses many of us is that's not at all obvious in the return string given in the instructions, which say "The record Brook Trout weighed..." so, it looks like we simply insert $this->species and $this->name again for "Brook Trout" in that string.