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