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 Build a Basic PHP Website (2018) Listing and Sorting Inventory Items Review Basics

PHP function issue on a task

Upon submitting my solution to this task, I get that the function is being pre-declared, when I am simply returning the value and assigning it to a variable. I will include my code bellow please advice further.

output.php
<?php
include "flavor.php";
function get_flavor(){
return $flavor;}

echo "Hal's favorite flavor of ice cream is ____.";

?>

1 Answer

Umesh Ravji
Umesh Ravji
42,386 Points

Hi Ioan, the get_flavor function is already written for us in flavor.php, just have to use it :)

You have to create the $flavor variable, and assign to it whatever is returned from calling get_flavor.

<?php
include "flavor.php";
$flavor = get_flavor();