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) Listing and Sorting Inventory Items Review Basics

James Barrett
James Barrett
13,253 Points

What is wrong with my code? Build a PHP website review

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

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

$flavor = get_flavor();

?>
output.php
<?php
include("flavor.php");

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

$flavor = get_flavor();

?>

3 Answers

Geovanie Alvarez
Geovanie Alvarez
21,500 Points

You have 2 problem: #1: the $flavor have to be before the echo statement, #2: in the echo you need a space between the "is" and the $flavor.

<?php
include("flavor.php");
$flavor = get_flavor(); // #1
echo "Hal's favorite flavor of ice cream is " . $flavor . "."; // #2
?>

You're probably just missing a space after the fist part of the sentence. This worked for me:

<?php

include('flavor.php');

$flavor = get_flavor();

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

?>

what no way this worked for you, you are doing it the other way around include shoud be first, then the declaration of the variable flavor, and then the echo statment!!

I just jumped into the challenge quickly and listed int in the order of the three challenges, but I agree that it seems weird and this is not the ideal way to display it here.