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 trialRegina Serrambana
1,961 PointsShould we include the HTML structure and php block above DOCTYPE declaration? Something is wrong but looks correct.
Are we supposed to include doctype and basic HTML structure? I've tried what I know to be correct code (it worked in the Treehouse workspace) but is not passing your 'check work' process.
<?php
$name = "Mike";
?>
<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8>
<title></title>
</head>
<body>
<p><?php echo $name ?></p>
</body>
</html>
2 Answers
Lucas Santos
19,315 PointsIt's probably not passing because you forgot the semicolon after $name. But you can declare your variable in the body like so:
<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8>
<title></title>
</head>
<body>
<?php $name = "Mike"; ?>
<p><?php echo $name; ?></p>
</body>
</html>
Jen Ollivierre
929 PointsFrom my experience, writing PHP code before the <!DOCTYPE html> is no issue. Doctype as it says, is for html :D