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 Build a Basic PHP Website (2018) Building a Media Library in PHP Variables and Conditionals

Carl Sergile
Carl Sergile
16,570 Points

Hey can't seem to figure out this question....

Getting the Treehouse oops box everytime I hit check work. I did the whole thing 3 times already.

index.php
<?php
$flavor = "vanilla";



if ($flavor == "cookie dough") {
  echo "Hal's favorite flavor is cookie dough, also!";
} else { 
  echo "Your favorite flavor of ice cream is $flavor";
}
echo $flavor();
?>

1 Answer

Damien Watson
Damien Watson
27,419 Points

Hey Carl,

I noticed you put '()' at the end of the last line, it will think that '$flavor' is a function call.

<?php
$flavor = "vanilla";

if ($flavor == "cookie dough") {
  echo "Hal's favorite flavor is cookie dough, also!";
} else { 
  echo "Your favorite flavor of ice cream is $flavor";
}
echo $flavor;

?>
Damien Watson
Damien Watson
27,419 Points

Initially I thought it was the 'else' as well, as the question says to return nothing on a match, but it seems to work either way.

Carl Sergile
Carl Sergile
16,570 Points

Nice thanks man! Was losing my mind for a min. Posted another php related question on arrays...