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 trialCarla Thomas
Front End Web Development Techdegree Student 16,039 PointsParenthesis within an <?php ?>
Below, how do I correctly place (1985) inside PHP tags?
<h1><?php echo $movie["title"] . '(1985)'; ?></h1>
5 Answers
Chris Southam
1,823 PointsI've just run through that one briefly now and it should be:
<h1><?php echo $movie['title'];?> (1985)</h1>
with the date outside of the PHP.
Tunde Adegoroye
20,597 Points<h1><?php echo '$movie["title"]' . '(1985)'; ?></h1>
Carla Thomas
Front End Web Development Techdegree Student 16,039 PointsHi Tunde...this was not the solution...but thanks for your help.
Chris Southam
1,823 PointsCarla Thomas Your version works just fine for me, displays the title and then (1985) within the H1. Not sure why you'd need it within the PHP tags though?
The other answer will echo out: $movie["title"](1985) since single quotes within an echo won't alter the PHP variables within.
Carla Thomas
Front End Web Development Techdegree Student 16,039 PointsHi Chris,
I am taking the PHP course here at teamtreehouse and the assignment is to wrap php within the html tags. This is the error message I get:
Bummer! It looks like the title of the second movie is in the <h1>, but something else isn't quite right. Double-check the parentheses and the year.
Carla Thomas
Front End Web Development Techdegree Student 16,039 PointsHi Chris,
I am taking the PHP course here at teamtreehouse and the assignment is to wrap php within the html tags. This is the error message I get:
Bummer! It looks like the title of the second movie is in the <h1>, but something else isn't quite right. Double-check the parentheses and the year.
Carla Thomas
Front End Web Development Techdegree Student 16,039 PointsThanks. As soon as I your work above, it all made sense. The HTML and PHP should remain separate, so (1985) should not have been included with the PHP nor did it need parenthesis because the browser was automatically interpreting it as HTML and not PHP.
You are AWESOME! Thanks again :)
Chris Southam
1,823 PointsNo worries - technically your code is correct but it's not the answer they were looking for.
Carla Thomas
Front End Web Development Techdegree Student 16,039 PointsCarla Thomas
Front End Web Development Techdegree Student 16,039 PointsThanks. As soon as I saw your work above, it all made sense. The HTML and PHP should remain separate, so (1985) should not have been included with the PHP nor did it need parenthesis because the browser was automatically interpreting it as HTML and not PHP.
You are AWESOME! Thanks again :)