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 trialdaniwao
13,125 PointsHow to call a function from different .php file!
Not sure what I'm doing wrong or what I'm missing. I would guess is that I'm either not "calling" the function the right way but I have the include or I'm not reading the directions right and I'm supposed to echo the return?
<?php include("flavor.php");
function get_flavor() { return $flavor; }
echo "Randy's favorite flavor of ice cream is ____.";
?>
2 Answers
Frances Leese
3,235 PointsYou dont need to write out the function, just call it.
so
$flavor = get_flavor();
Shawn Gregory
Courses Plus Student 40,672 PointsHello,
The function is already defined in the file you are including. The code challenge is asking you to:
- Include the file
- Assign what's returned from the function to a variable (the name of the variable is in the instructions)
- Use that variable inside of the echo statement to display what the function returns with the phrase that's already there.
This should make the code challenge pass.
Cheers!