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 trialJonathan Tebb
672 PointsI'm not sure why the string 'title' in the $movie array is not printing on the page as a result of my lines 2 and 3.
I'm not sure why the string 'title' in the $movie array is not printing on the page as a result of my lines 2 and 3.
<?php
echo '<h1>' . $movie["title"] , "(1985)" . '</h1>';
$movie = array( "title" => "The Empire Strikes Back")
?>
<table>
<tr>
<th>Director</th>
<td>Robert Zemeckis</td>
</tr>
<tr>
<th>IMDB Rating</th>
<td>8.5</td>
</tr>
<tr>
<th>IMDB Ranking</th>
<td>53</td>
</tr>
</table>
2 Answers
Meghan Tucker
Front End Web Development Techdegree Graduate 33,189 PointsThere are a couple small things in the code to watch out for: 1) (I'm not certain) but I'm pretty sure that php works similarly to CSS or Javascript in that you must declare things before you use them. Try putting your variable declaration first, so that when you reference your variable later the program knows what to pull from (please correct me if I'm wrong about that). 2) you're missing a semicolon to end your statement on line 3 ($movie = array(blah, blah); . and 3) I'm not sure if you have to do this, but it worked for me to place the statement referencing the year and the movie in its own php tag inside the <h1> tags, rather than pulling the <h1> tags out from the html section and into the php section. My end result looked like this:
<?php
$movie = array("title" => "The Empire Strikes Back");
?>
<h1><?php echo $movie["title"] ; ?> (1985)</h1>
<table>
Hope this helps! Happy coding.
Jonathan Tebb
672 PointsIt works now I needed all three of those tips for it to work