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 trialJeffrey Cheong
5,653 PointsProblems adding the "Hello World" to the browser.
I am adding <p><?php echo "Hello, World!" ?></p> to the section tag and it does not show on the preview page. It shows when inspect the element as just
<p><?php echo "Hello, World!" ?></p>
instead of
<p>Hello World!</p>
Is it just a problem with the workspace or am I doing something wrong?
6 Answers
Roy Penrod
19,810 PointsWhat does your code look like?
We really need to see it to be able to tell what's going wrong.
Jeffrey Cheong
5,653 Pointsthats strange, I tried adding "<p><?php echo "Hello, World!" ?></p>" to the comment (without the "") and it didn't work.
Roy Penrod
19,810 PointsHey, Jeffrey ... you couldn't post the code because you were using single quotes. What you need to use is the back quote key. Most keyboards have it just to the left of the number 1.
I did the same thing the first time I tried to post a code sample.
Roy Penrod
19,810 PointsBased on what you typed, it looks like you forgot the opening php tag. Here's what it should look like:
<p><?php echo "Hello World"; ?></p>
Jeffrey Cheong
5,653 PointsSorry but the code is not showing, maybe this will work: "paragraph tag"<?php echo "Hello, World!" ?>"/paragraph tag"
Jeffrey Cheong
5,653 PointsYeah that's what I have in my html workspace, and it's not showing in the preview and when I inspect the element it just looks like what is above except in place of the paragraph tags there are comment tags.
Roy Penrod
19,810 PointsSounds like you've got a comment tag surrounding it somewhere in your source code.
Look for these tags and remove them if they're around the php statement:
<!-- <-- remove that tag
--> <-- remove that tag
Jeffrey Cheong
5,653 PointsHey Roy thanks for the help but it was just a minor error that I missed, apparently I had to change the index.html to index.php but workspace started it up in index.html I don't know why.
Jeffrey Cheong
5,653 PointsI don't have the comment tags in my source code this is what I have in that section tag exactly and it doesn't seem to work.
<section class="main">
<p>Let's Get Started!</p>
<p><?php echo "Hello World"; ?></p>
</section>
Roy Penrod
19,810 PointsAh, I see. Yep, the .php extension will do it. Glad you figure it out.
Jeffrey Cheong
5,653 PointsJeffrey Cheong
5,653 PointsSorry, when I inspect the element it shows <!--?php "Hello World" ?-->.