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

Code review

Can someone help me in this scenario?

<?php include('flavor.php'); echo "Randy's favorite flavor of ice cream is ____."; $flavor = ""; function get_flavor(){ return $flavor; } ?>

I can't make it work. Thank you :)

Richard Duncan
Richard Duncan
5,568 Points

Yes but can you post the challenge question please?

2 Answers

Hi HERNAN,

Compare your code (fiRST) to my code (second). The get_flavor Function has already been created in the flavor.php file, all you need to do is call the function. You're re-creating the function.

Jeff

<?php
include('flavor.php');

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

$flavor = "";

function get_flavor(){
  return $flavor;
}
?>
=============================================

<?php

include 'flavor.php';

$flavor = get_flavor();

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

?>

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

Thank you very much Jeff! I was going insane trying to re-define the function, and the function was already in the include file... i just had to call it :)

The link to display code at Treehouse is also very useful. I'm definitly gonna read it!

Yes, sorry...

"The flavor.php include file contains a function named get_flavor. That function receives no arguments, and it returns a piece of text as its return value. Call that function and assign the return value to a variable named flavor."

This last sentence is what i'm trying to do... but does not work :(