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 trialRitual Zebra
1,755 PointsPHP Becoming a comment in HTML
Hello! I recently started getting into PHP, and when I try to make the <?php echo $example ?>, for example all my HTML, CSS, and or PHP editors try to make it as a comment. Also when I inspect element with google chrome. Not sure why this happens but if somebody could help me that would be great!
3 Answers
Tim Knight
28,888 PointsHi Logan,
You mentioned that all "editors" so I'm assuming you mean text editors you're editing your code with? If you're using Sublime Text or a similar editor are you using HTML syntax or PHP syntax in the editor? And just to confirm, and I apologize if this has been addressed in the comments above, but you are running this through a PHP server correct? Just loading the file in your browser will not produce the expected result. You'll need something like MAMP, WAMP, or something similar to get you going.
Scott Evans
4,236 PointsThis seems like whats going on to me also.
Sergio Alen
26,726 Pointsyou're right, that must be the problem, not running local server
Sergio Alen
26,726 PointsThere seems to be a syntax error on line 18 on the meta tag missing the double quotes, see below:
<meta charset="UTF-8">
See if that makes a difference
Also your missing closing semi-colons after your echo function
<h1><?php echo $name; ?></h1>
<p><?php echo $location; ?></p>
Did you save your file with .php extension?
Sergio Alen
26,726 PointsTry and remove all instances of PHP, and slowly add them back, start by removing your constants and variables and echo a string with your name instead of the variable, like this:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Treehouse Profile</title>
<link href="css/style.css" rel="stylesheet" />
</head>
<body>
<section class="sidebar text-center">
<div class="avatar">
<img src="img/avatar.png" alt="">
</div>
<h1><?php echo 'Logan'; ?></h1>
<p><?php echo 'Somewhere'; ?></p>
<hr />
<p>Welcome to PHP Basics!</p>
<hr />
<ul class="social">
<li><a href=""><span class="icon twitter"></span></a></li>
</ul>
</section>
<section class="main">
<pre>
</pre>
</section>
</body>
</html>
if it works then start adding back the rest of your code.
Good luck!
Sergio Alen
26,726 PointsSergio Alen
26,726 PointsHey Logan can you post your code? use the markdown cheatsheet right above the "post answer" button to learn how to.