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

PHP Enhancing a Simple PHP Application Integrating Validation Errors Reviewing PHP Basics

Jason Slabbers
Jason Slabbers
4,447 Points

Can't get return value of get_flavor.

I need some help with this code challenge.

i've tried many approaches to get the return value of get_flavor, but it will not work (step 3 in the challenge).

Can you help me with some tips where to look to get the right return value?

Many thanks in advance!

Hi Jason, can we see your code?

4 Answers

Cherie Burgett
Cherie Burgett
8,711 Points

get_flavor is already a predefined function so no need to rename it as a function again. You included it in step 1.

$flavor = get_flavor(); echo "Randy's favorite flavor of ice cream is " . $flavor . ".";

Jason,

You are adding a return statement to a function that already returns a value. We assigned the return value to $flavor aleady: $flavor = get_flavor();. Now we just use $flavor to use that value. Check it out below. Also:

If you look to the bottom right of the text box you will see something that says Markdown Cheetsheet. If you don't understand that maybe this will make sense: How to display code at Treehouse

Jeff

echo "Randy's favorite flavor of ice cream is " . $flavor . ".";
Jason Slabbers
Jason Slabbers
4,447 Points
<?php include("flavor.php"); ?>

<?php
function get_flavor() {
  $flavor = "";

  return $flavor;
}
?>
<?php

echo "Randy's favorite flavor of ice cream is " . $flavor . ".";

?>
Jason Slabbers
Jason Slabbers
4,447 Points

Thanks Cherie! I was thinking 1 step to far I think.