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

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