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