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 trialWillie Allison
2,035 Pointstask two on intermediate PHP, how do you call the function and assign it to the variable?
I am working on task 2 of 3 on the intermediate level of PHP and I need to call the function and assign it to the variable for an echo output. Can anyone help with this? The code view is not working for me so I can't test my code before checking my work.
<?php
include('flavor.php');
function get_flavor(){
$flavor -> get_flavor(){
}
return $flavor;
}
echo "Randy's favorite flavor of ice cream is " . $flavor;
?>
2 Answers
Emma Willmann
Treehouse Project ReviewerTask 2 says the include file already includes the function. So this code you wrote:
function get_flavor(){
$flavor -> get_flavor(){
}
return $flavor;
}
is in that file. You just need to call it, and assign it to a variable. Your code should look like this:
<?php
include ('flavor.php');
$flavor = get_flavor();
echo "Randy's favorite flavor of ice cream is ____.";
?>
shezazr
8,275 Pointsyou have read the question wrong! it says the function already exists so you dont need to create it! Just try to call it & assign it to a variable!
let me know if you have any problems with this