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 trialJames Barrett
13,253 PointsWhat 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();
?>
<?php
include("flavor.php");
echo "Hal's favorite flavor of ice cream is" . $flavor . ".";
$flavor = get_flavor();
?>
3 Answers
Geovanie Alvarez
21,500 PointsYou 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
?>
rvandaalen
24,090 PointsYou'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 . ".";
?>
michaelleonard4
7,013 Pointswhat 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!!
rvandaalen
24,090 PointsI 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.
James Barrett
13,253 PointsJames Barrett
13,253 PointsGreat, thanks