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 Enhancing a Simple PHP Application Integrating Validation Errors Reviewing PHP Basics

Ilya Liverts
Ilya Liverts
9,677 Points

Can't solve second task.

<?php include("flavor.php"); var flavor = get_flavor(); echo "Randy's favorite flavor of ice cream is ____.";

?>

This code does not work. I can't find why.

2 Answers

To define you're variable, you'll want to use a dollar sign.

Spoiler

<?php
include('flavor.php');
$flavor = get_flavor();
echo "Randy's favorite flavor of ice cream is ____.";

?>

As said above, you can't declare variables in PHP using <code>var variable_name = value;</code>, this is JavaScript :) Instead you would use the <code>$variable_name = value</code> format.

Correct code

<?php
    include('flavor.php');
    $flavor = get_flavor();
    echo "Randy's favorite flavor of ice cream is ____.";
?>