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 trialIacob Silviu
5,608 PointsIssue with my code? Don't seem to find the problem.
Greetings ! I've been struggling for a while now, and I don't seem to understand why my code is not working. It is about Challenge Task 5 at the end of the properties and methods lessons for OOPhP .
public function getInfo(){
echo "A " . $this->common_name . " is an " . $this->flavor . " flavored fish. The World record weight is " . $this->record_weight . ".";
}
Thanks O_O
2 Answers
Shawn Gregory
Courses Plus Student 40,672 PointsHello,
Your problem stems from how you are using the phrase in the function. The function name is getInfo() so it's what's called a getter function. A getter function grabs a value or values in a class and "returns" it back to you. A getter function doesn't print out what it's retrieving, it returns what it's retrieving. You need to return your phrase not display it as later on you will be echoing out what is returned from this function.
Cheers!
Iacob Silviu
5,608 PointsThank you !