Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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

Willie Allison
Willie Allison
2,035 Points

task 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.

output.php
<?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
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Emma Willmann
Treehouse Project Reviewer

Task 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 ____.";

?>

you 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